commit 0e120abe46b29d6c3f3d00d6fda467a3f8949d37
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu Aug 27 15:59:24 2015 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
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
@@ -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);
        }
 }
 

Reply via email to