[hackers] [scc] Fix check of invalid field in expressions || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 27 Aug 2015 16:16:37 +0200 (CEST)

commit 0e120abe46b29d6c3f3d00d6fda467a3f8949d37
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 27 15:59:24 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 27 15:59:24 2015 +0200

    Fix check of invalid field in expressions
    
    It is impossible to have yylval.sym == NULL when yytoken == IDEN,
    but the symbol not have the ISDECLARED flag.

diff --git a/cc1/expr.c b/cc1/expr.c
index 437f38b..107e075 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -681,23 +681,26 @@ field(Node *np)
 {
         Symbol *sym;
 
+ namespace = np->type->ns;
+ next();
+ namespace = NS_IDEN;
+
+ sym = yylval.sym;
+ if (yytoken != IDEN)
+ unexpected();
+ next();
+
         switch (BTYPE(np)) {
         case STRUCT:
         case UNION:
- namespace = np->type->ns;
- next();
- namespace = NS_IDEN;
-
- if (yytoken != IDEN)
- unexpected();
- if ((sym = yylval.sym) == NULL)
+ if ((sym->flags & ISDECLARED) == 0)
                         error("incorrect field in struct/union");
- next();
                 np = node(OFIELD, sym->type, np, varnode(sym));
                 np->lvalue = 1;
                 return np;
         default:
- error("struct or union expected");
+ error("request for member '%s' in something not a structure or union",
+ yylval.sym->name);
         }
 }
 
Received on Thu Aug 27 2015 - 16:16:37 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 27 2015 - 16:24:16 CEST