Merge pull request #2298 from acqn/Diagnostics

[cc65] More accurate diagnostic messages on empty declarations without any type specifiers
This commit is contained in:
Bob Andrews 2023-12-12 17:06:54 +01:00 committed by GitHub
commit e90e7f46de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -2087,10 +2087,13 @@ static void DirectDecl (DeclSpec* Spec, Declarator* D, declmode_t Mode)
NextToken ();
} else {
D->Ident[0] = '\0';
if ((Spec->Flags & DS_NO_EMPTY_DECL) != 0 &&
CurTok.Tok != TOK_LBRACK &&
if (CurTok.Tok != TOK_LBRACK &&
((Spec->Flags & DS_ALLOW_BITFIELD) == 0 || CurTok.Tok != TOK_COLON)) {
Error ("Identifier expected");
if ((Spec->Flags & DS_TYPE_MASK) == DS_DEF_TYPE) {
Error ("Declaration specifier or identifier expected");
} else if ((Spec->Flags & DS_NO_EMPTY_DECL) != 0) {
Error ("Identifier expected");
}
}
}

View File

@ -1412,7 +1412,7 @@ static void Primary (ExprDesc* E)
} else {
/* Let's see if this is a C99-style declaration */
DeclSpec Spec;
ParseDeclSpec (&Spec, TS_DEFAULT_TYPE_NONE, SC_AUTO);
ParseDeclSpec (&Spec, TS_DEFAULT_TYPE_INT, SC_AUTO);
if ((Spec.Flags & DS_TYPE_MASK) != DS_NONE) {
Error ("Mixed declarations and code are not supported in cc65");

View File

@ -1,3 +1,3 @@
bug1889-missing-identifier.c:3: Error: Identifier or ';' expected after declaration specifiers
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: Error: Declaration specifier or identifier expected