scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 28eee94b1bba0e336f766a30e0c90e0331d0da4b
parent 9efb947d3ec79570f070e89c0020490f5ffa43d4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 10 Dec 2016 08:37:23 +0100

Merge branch 'master' of ssh://suckless.org/gitrepos/scc

Diffstat:
Mcc1/code.c | 2+-
Mcc1/decl.c | 15+++++++--------
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -252,7 +252,7 @@ emittype(Type *tp) emitletter(tp); putchar('\t'); emitletter(tp->type); - printf("\t#%c%lld\n", + printf("\t#%c%llX\n", sizettype->letter, (long long) tp->n.elem); return; case PTR: 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)