From e925aa27eebaf734203cc5f57f8c532c379708c8 Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 6 Mar 2003 12:12:25 +0000 Subject: [PATCH] Improve error recovery git-svn-id: svn://svn.cc65.org/cc65/trunk@2002 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/declare.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; } -- 2.39.5