commit 3cf019b73b85b299a440079026905b0fecbe82ff
parent 0e5c97b6bbb089afe3a34ecb2ffbbaf960580d61
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 2 Sep 2015 22:33:16 +0200
Print only one error for every non declared variable
After the change in the symbol table, flaging the symbol as declared
is not enough, we have to install it in the symbol table.
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -508,6 +508,7 @@ static Node *
primary(void)
{
Node *np;
+ Symbol *sym;
switch (yytoken) {
case CONSTANT:
@@ -515,13 +516,14 @@ primary(void)
next();
break;
case IDEN:
- if ((yylval.sym->flags & ISDECLARED) == 0) {
- yylval.sym->type = inttype;
- yylval.sym->flags |= ISDECLARED;
- error("'%s' undeclared", yytext);
+ sym = yylval.sym;
+ if ((sym->flags & ISDECLARED) == 0) {
+ errorp("'%s' undeclared", yytext);
+ sym->type = inttype;
+ install(sym->ns, yylval.sym);
}
- yylval.sym->flags |= ISUSED;
- np = varnode(yylval.sym);
+ sym->flags |= ISUSED;
+ np = varnode(sym);
next();
break;
default: