/* */
/* */
/* */
-/* (C) 1998-2008 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
}
break;
+ case TOK_CDECL:
+ if (Allowed & T_QUAL_CDECL) {
+ if (Q & T_QUAL_CDECL) {
+ DuplicateQualifier ("cdecl");
+ }
+ Q |= T_QUAL_CDECL;
+ } else {
+ goto Done;
+ }
+ break;
+
default:
goto Done;
Q &= ~T_QUAL_ADDRSIZE;
}
+ /* We cannot have more than one calling convention specifier */
+ switch (Q & T_QUAL_CCONV) {
+
+ case T_QUAL_NONE:
+ case T_QUAL_FASTCALL:
+ case T_QUAL_CDECL:
+ break;
+
+ default:
+ Error ("Cannot specify more than one calling convention qualifier");
+ Q &= ~T_QUAL_CCONV;
+ }
+
/* Return the qualifiers read */
return Q;
}
static void ParseOldStyleParamList (FuncDesc* F)
/* Parse an old style (K&R) parameter list */
{
+ /* Some fix point tokens that are used for error recovery */
+ static const token_t TokenList[] = { TOK_COMMA, TOK_RPAREN, TOK_SEMI };
+
/* Parse params */
while (CurTok.Tok != TOK_RPAREN) {
/* List of identifiers expected */
- if (CurTok.Tok != TOK_IDENT) {
- Error ("Identifier expected");
- }
+ if (CurTok.Tok == TOK_IDENT) {
- /* Create a symbol table entry with type int */
- AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF | SC_DEFTYPE, 0);
+ /* Create a symbol table entry with type int */
+ AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF | SC_DEFTYPE, 0);
- /* Count arguments */
- ++F->ParamCount;
+ /* Count arguments */
+ ++F->ParamCount;
- /* Skip the identifier */
- NextToken ();
+ /* Skip the identifier */
+ NextToken ();
+
+ } else {
+ /* Not a parameter name */
+ Error ("Identifier expected");
+
+ /* Try some smart error recovery */
+ SkipTokens (TokenList, sizeof(TokenList) / sizeof(TokenList[0]));
+ }
/* Check for more parameters */
if (CurTok.Tok == TOK_COMMA) {
/* We cannot specify fastcall for variadic functions */
if ((F->Flags & FD_VARIADIC) && (Qualifiers & T_QUAL_FASTCALL)) {
- Error ("Variadic functions cannot be `__fastcall'");
+ Error ("Variadic functions cannot be `__fastcall__'");
Qualifiers &= ~T_QUAL_FASTCALL;
}
if (Qualifiers & T_QUAL_FASTCALL) {
Error ("Invalid `__fastcall__' qualifier");
}
+ if (Qualifiers & T_QUAL_CDECL) {
+ Error ("Invalid `__cdecl__' qualifier");
+ }
}