From: cuz Date: Thu, 6 Mar 2003 12:12:25 +0000 (+0000) Subject: Improve error recovery X-Git-Tag: V2.12.0~1690 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e925aa27eebaf734203cc5f57f8c532c379708c8;p=cc65 Improve error recovery git-svn-id: svn://svn.cc65.org/cc65/trunk@2002 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/declare.c b/src/cc65/declare.c index b6e78e27c..6d0c47f5e 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1084,6 +1084,9 @@ static unsigned ParseStructInit (type* Type, int AllowFlexibleMembers) unsigned StructSize; unsigned Size; + static const token_t EndTokens[] = { TOK_RCURLY, TOK_SEMI }; + + /* Consume the opening curly brace */ ConsumeLCurly (); @@ -1099,7 +1102,12 @@ static unsigned ParseStructInit (type* Type, int AllowFlexibleMembers) Tab = Entry->V.S.SymTab; if (Tab == 0) { Error ("Cannot initialize variables with incomplete type"); - /* Returning here will cause lots of errors, but recovery is difficult */ + /* Try error recovery */ + SkipTokens (EndTokens, sizeof(EndTokens)/sizeof(EndTokens[0])); + if (CurTok.Tok == TOK_RCURLY) { + NextToken (); + } + /* Nothing initialized */ return 0; }