1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-08 06:25:17 +00:00

Merge pull request #1900 from acqn/Diagnostics

[cc65] Fixed endlessly repeated error messages when a declaration lacks a required identifier
This commit is contained in:
Bob Andrews
2022-11-11 21:08:53 +01:00
committed by GitHub
4 changed files with 24 additions and 2 deletions

View File

@@ -1453,9 +1453,8 @@ static void ParseTypeSpec (DeclSpec* D, typespec_t TSFlags, int* SignednessSpeci
} else { } else {
if (CurTok.Tok != TOK_LCURLY) { if (CurTok.Tok != TOK_LCURLY) {
Error ("Identifier expected"); Error ("Identifier expected");
} else {
AnonName (Ident, "enum");
} }
AnonName (Ident, "enum");
} }
/* Remember we have an extra type decl */ /* Remember we have an extra type decl */
D->Flags |= DS_EXTRA_TYPE; D->Flags |= DS_EXTRA_TYPE;
@@ -1867,7 +1866,13 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
NextToken (); NextToken ();
} else { } else {
if (Mode == DM_NEED_IDENT) { if (Mode == DM_NEED_IDENT) {
/* Some fix point tokens that are used for error recovery */
static const token_t TokenList[] = { TOK_COMMA, TOK_SEMI };
Error ("Identifier expected"); Error ("Identifier expected");
/* Try some smart error recovery */
SkipTokens (TokenList, sizeof(TokenList) / sizeof(TokenList[0]));
} }
D->Ident[0] = '\0'; D->Ident[0] = '\0';
} }

View File

@@ -161,6 +161,11 @@ $(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
$(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out $(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
$(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref $(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref
$(WORKDIR)/bug1889-missing-identifier.$1.$2.prg: bug1889-missing-identifier.c $(ISEQUAL) | $(WORKDIR)
$(if $(QUIET),echo misc/bug1889-missing-identifier.$1.$2.error.prg)
-$(CC65) -t sim$2 -$1 -o $$(@:.error.prg=.s) $$< 2> $(WORKDIR)/bug1889-missing-identifier.$1.$2.out
$(ISEQUAL) $(WORKDIR)/bug1889-missing-identifier.$1.$2.out bug1889-missing-identifier.ref
# the rest are tests that fail currently for one reason or another # the rest are tests that fail currently for one reason or another
$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR) $(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
@echo "FIXME: " $$@ "currently does not compile." @echo "FIXME: " $$@ "currently does not compile."

View File

@@ -0,0 +1,9 @@
/* bug 1889 - endless errors due to failure in recovery from missing identifier */
int enum { a } x;
inline enum { b };
int main(void)
{
return 0;
}

View File

@@ -0,0 +1,3 @@
bug1889-missing-identifier.c:3: Error: Identifier expected
bug1889-missing-identifier.c:4: Error: Identifier expected
bug1889-missing-identifier.c:4: Warning: Implicit 'int' is an obsolete feature