From: uz Date: Sun, 18 Sep 2011 20:36:19 +0000 (+0000) Subject: Fixed an internal error caused by muddling through after an error occurred and X-Git-Tag: V2.13.3~163 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ab83d5cd78f1a371910216f01ca7014e189b6dee;p=cc65 Fixed an internal error caused by muddling through after an error occurred and trying to add a duplicate identifier into the symbol table. git-svn-id: svn://svn.cc65.org/cc65/trunk@5300 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 93331f160..cf31728c7 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1050,22 +1050,31 @@ static Type* ParamTypeCvt (Type* T) 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) {