mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Reduced error flood raised by misplaced variable declarations.
This commit is contained in:
parent
0f1a5e0520
commit
68d63b089d
@ -263,7 +263,7 @@ static void OptionalSigned (void)
|
||||
|
||||
|
||||
|
||||
static void InitDeclSpec (DeclSpec* D)
|
||||
void InitDeclSpec (DeclSpec* D)
|
||||
/* Initialize the DeclSpec struct for use */
|
||||
{
|
||||
D->StorageClass = 0;
|
||||
|
@ -93,6 +93,9 @@ typedef enum {
|
||||
|
||||
|
||||
|
||||
void InitDeclSpec (DeclSpec* D);
|
||||
/* Initialize the DeclSpec struct for use */
|
||||
|
||||
Type* ParseType (Type* Type);
|
||||
/* Parse a complete type specification */
|
||||
|
||||
|
@ -920,8 +920,35 @@ static void Primary (ExprDesc* E)
|
||||
/* Illegal primary. Be sure to skip the token to avoid endless
|
||||
** error loops.
|
||||
*/
|
||||
{
|
||||
/* Let's see if this is a C99-style declaration */
|
||||
DeclSpec Spec;
|
||||
InitDeclSpec (&Spec);
|
||||
ParseDeclSpec (&Spec, -1, T_QUAL_NONE);
|
||||
|
||||
if (Spec.Type->C != T_END) {
|
||||
|
||||
Error ("Mixed declarations and code are not supported in cc65");
|
||||
while (CurTok.Tok != TOK_SEMI) {
|
||||
Declaration Decl;
|
||||
|
||||
/* Parse one declaration */
|
||||
ParseDecl (&Spec, &Decl, DM_ACCEPT_IDENT);
|
||||
if (CurTok.Tok == TOK_ASSIGN) {
|
||||
NextToken ();
|
||||
ParseInit (Decl.Type);
|
||||
}
|
||||
if (CurTok.Tok == TOK_COMMA) {
|
||||
NextToken ();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Error ("Expression expected");
|
||||
NextToken ();
|
||||
}
|
||||
}
|
||||
ED_MakeConstAbsInt (E, 1);
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user