commit 53524f0343fd7d547953ab39b09f336d661d4d88
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Fri Jan 8 12:33:02 2016 +0100
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Fri Jan 8 12:33:02 2016 +0100

    Convert fielddesig() and field() to use new type fields

diff --git a/cc1/expr.c b/cc1/expr.c
index 86a4176..3542a81 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -441,18 +441,22 @@ field(Node *np)
                unexpected();
        next();
 
-       switch (BTYPE(np)) {
-       case STRUCT:
-       case UNION:
-               if ((sym->flags & ISDECLARED) == 0)
-                       error("incorrect field in struct/union");
-               np = node(OFIELD, sym->type, np, varnode(sym));
-               np->lvalue = 1;
-               return np;
-       default:
-               error("request for member '%s' in something not a structure or 
union",
+       if (!np->type->aggreg) {
+               errorp("request for member '%s' in something not a structure or 
union",
                      yylval.sym->name);
+               goto free_np;
        }
+       if ((sym->flags & ISDECLARED) == 0) {
+               errorp("incorrect field in struct/union");
+               goto free_np;
+       }
+       np = node(OFIELD, sym->type, np, varnode(sym));
+       np->lvalue = 1;
+       return np;
+
+free_np:
+       freetree(np);
+       return constnode(zero);
 }
 
 static Node *
@@ -1105,7 +1109,7 @@ fielddesig(Type *tp)
        int ons;
        Symbol *sym, **p;
 
-       if (tp->op != STRUCT || tp->op != UNION)
+       if (!tp->aggreg)
                errorp("field name not in record or union initializer");
        ons = namespace;
        namespace = tp->ns;

Reply via email to