[hackers] [scc] Convert fielddesig() and field() to use new type fields || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 8 Jan 2016 13:14:01 +0100 (CET)

commit 53524f0343fd7d547953ab39b09f336d661d4d88
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jan 8 12:33:02 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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 *
_AT_@ -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;
Received on Fri Jan 08 2016 - 13:14:01 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 08 2016 - 13:25:14 CET