diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 3367b04d7..99161e539 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1891,12 +1891,21 @@ static void DirectDecl (const DeclSpec* Spec, Declarator* D, declmode_t Mode) } else { if (Mode == DM_NEED_IDENT) { /* Some fix point tokens that are used for error recovery */ - static const token_t TokenList[] = { TOK_COMMA, TOK_SEMI }; + static const token_t TokenList[] = { TOK_COMMA, TOK_SEMI, TOK_LCURLY, TOK_RCURLY }; Error ("Identifier expected"); /* Try some smart error recovery */ SkipTokens (TokenList, sizeof(TokenList) / sizeof(TokenList[0])); + + /* Skip curly braces */ + if (CurTok.Tok == TOK_LCURLY) { + static const token_t CurlyToken[] = { TOK_RCURLY }; + SkipTokens (CurlyToken, sizeof(CurlyToken) / sizeof(CurlyToken[0])); + NextToken (); + } else if (CurTok.Tok == TOK_RCURLY) { + NextToken (); + } } D->Ident[0] = '\0'; } diff --git a/test/ref/bug1889-missing-identifier.cref b/test/ref/bug1889-missing-identifier.cref index cd3f76849..acaf53f94 100644 --- a/test/ref/bug1889-missing-identifier.cref +++ b/test/ref/bug1889-missing-identifier.cref @@ -1,3 +1,5 @@ bug1889-missing-identifier.c:3: Error: Identifier expected +bug1889-missing-identifier.c:3: Error: ';' expected +bug1889-missing-identifier.c:3: Warning: Implicit 'int' is an obsolete feature bug1889-missing-identifier.c:4: Error: Identifier expected bug1889-missing-identifier.c:4: Warning: Implicit 'int' is an obsolete feature