ref: 0e120abe46b29d6c3f3d00d6fda467a3f8949d37
parent: a9f59c62a1ef80c97cbf32e3aa11410f7ef9f455
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Aug 27 11:59:24 EDT 2015
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.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -681,23 +681,26 @@
{
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);
}
}