[hackers] [scc] Print only one error for every non declared variable || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 2 Sep 2015 22:35:27 +0200 (CEST)

commit 3cf019b73b85b299a440079026905b0fecbe82ff
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Sep 2 22:33:16 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Sep 2 22:33:16 2015 +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.

diff --git a/cc1/expr.c b/cc1/expr.c
index afb7a73..668dcfb 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -508,6 +508,7 @@ static Node *
 primary(void)
 {
         Node *np;
+ Symbol *sym;
 
         switch (yytoken) {
         case CONSTANT:
_AT_@ -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:
Received on Wed Sep 02 2015 - 22:35:27 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 02 2015 - 22:36:11 CEST