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
This commit is contained in:
uz
2011-09-18 20:36:19 +00:00
parent a9de1a9e89
commit ab83d5cd78

View File

@@ -1050,13 +1050,14 @@ static Type* ParamTypeCvt (Type* T)
static void ParseOldStyleParamList (FuncDesc* F) static void ParseOldStyleParamList (FuncDesc* F)
/* Parse an old style (K&R) parameter list */ /* 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 */ /* Parse params */
while (CurTok.Tok != TOK_RPAREN) { while (CurTok.Tok != TOK_RPAREN) {
/* List of identifiers expected */ /* List of identifiers expected */
if (CurTok.Tok != TOK_IDENT) { if (CurTok.Tok == TOK_IDENT) {
Error ("Identifier expected");
}
/* Create a symbol table entry with type int */ /* Create a symbol table entry with type int */
AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF | SC_DEFTYPE, 0); AddLocalSym (CurTok.Ident, type_int, SC_AUTO | SC_PARAM | SC_DEF | SC_DEFTYPE, 0);
@@ -1067,6 +1068,14 @@ static void ParseOldStyleParamList (FuncDesc* F)
/* Skip the identifier */ /* Skip the identifier */
NextToken (); 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 */ /* Check for more parameters */
if (CurTok.Tok == TOK_COMMA) { if (CurTok.Tok == TOK_COMMA) {
NextToken (); NextToken ();