ref: 3cf019b73b85b299a440079026905b0fecbe82ff
parent: 0e5c97b6bbb089afe3a34ecb2ffbbaf960580d61
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Sep 2 18:33:16 EDT 2015
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.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -508,6 +508,7 @@
primary(void)
{
Node *np;
+ Symbol *sym;
switch (yytoken) {
case CONSTANT:
@@ -515,13 +516,14 @@
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: