commit 47eff6965a28547891e871c7f499bee5d396ef25
parent 3416241f55a7f93c93ca5374a532fa194c4f6292
Author: Quentin Carbonneaux <quentin@c9x.me>
Date: Fri, 9 Dec 2016 17:15:10 -0500
[cc1] Remove macro in field()
Diffstat:
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -609,12 +609,12 @@ type(struct decl *dcl)
return sym;
}
-#define NAME(s) (*(s)->name ? (s)->name : "<anonymous>")
static Symbol *
field(struct decl *dcl)
{
+ static char *anon = "<anonymous>";
Symbol *sym = dcl->sym;
- char *name = sym->name;
+ char *name = *sym->name ? sym->name : anon;
Type *structp = dcl->parent, *tp = dcl->type;
TINT n = structp->n.elem;
int err = 0;
@@ -631,14 +631,14 @@ field(struct decl *dcl)
n = np->sym->u.i;
freetree(np);
}
- if (n == 0 && *sym->name)
- errorp("zero width for bit-field '%s'", sym->name);
+ if (n == 0 && name != anon)
+ errorp("zero width for bit-field '%s'", name);
if (tp != booltype && tp != inttype && tp != uinttype)
- errorp("bit-field '%s' has invalid type", NAME(sym));
+ errorp("bit-field '%s' has invalid type", name);
if (n < 0)
- errorp("negative width in bit-field '%s'", NAME(sym));
+ errorp("negative width in bit-field '%s'", name);
else if (n > tp->size*8)
- errorp("width of '%s' exceeds its type", NAME(sym));
+ errorp("width of '%s' exceeds its type", name);
} else if (empty(sym, tp, 0)) {
return sym;
}
@@ -672,7 +672,6 @@ field(struct decl *dcl)
return sym;
}
-#undef NAME
static void
bad_storage(Type *tp, char *name)