diff options
-rw-r--r-- | cc.h | 2 | ||||
-rw-r--r-- | decl.c | 16 | ||||
-rw-r--r-- | qbe.c | 7 |
3 files changed, 10 insertions, 15 deletions
@@ -268,6 +268,7 @@ struct decl { struct type *type; enum typequal qual; struct value *value; + char *asmname; _Bool defined; /* link in list of tentative object definitions */ @@ -523,7 +524,6 @@ void switchcase(struct switchcases *, unsigned long long, struct block *); struct block *mkblock(char *); struct value *mkglobal(char *, _Bool); -char *globalname(struct value *); struct value *mkintconst(unsigned long long); unsigned long long intconstvalue(struct value *); @@ -833,7 +833,6 @@ declcommon(struct scope *s, enum declkind kind, char *name, char *asmname, struc struct decl *d; enum linkage linkage; const char *kindstr = kind == DECLFUNC ? "function" : "object"; - char *priorname; if (prior) { if (prior->linkage == LINKNONE) @@ -843,7 +842,7 @@ declcommon(struct scope *s, enum declkind kind, char *name, char *asmname, struc error(&tok.loc, "%s '%s' redeclared with different linkage", kindstr, name); if (!typecompatible(t, prior->type) || tq != prior->qual) error(&tok.loc, "%s '%s' redeclared with incompatible type", kindstr, name); - if (asmname && strcmp(globalname(prior->value), asmname) != 0) + if (asmname && (!prior->asmname || strcmp(prior->asmname, asmname) != 0)) error(&tok.loc, "%s '%s' redeclared with different assembler name", kindstr, name); prior->type = typecomposite(t, prior->type); return prior; @@ -862,18 +861,21 @@ declcommon(struct scope *s, enum declkind kind, char *name, char *asmname, struc error(&tok.loc, "%s '%s' redeclared with different linkage", kindstr, name); if (!typecompatible(t, prior->type) || tq != prior->qual) error(&tok.loc, "%s '%s' redeclared with incompatible type", kindstr, name); - priorname = globalname(prior->value); if (!asmname) - asmname = priorname; - else if (strcmp(priorname, asmname) != 0) + asmname = prior->asmname; + else if (!prior->asmname || strcmp(prior->asmname, asmname) != 0) error(&tok.loc, "%s '%s' redeclared with different assembler name", kindstr, name); t = typecomposite(t, prior->type); } } d = mkdecl(kind, t, tq, linkage); scopeputdecl(s, name, d); - if (kind == DECLFUNC || linkage != LINKNONE || sc & SCSTATIC) - d->value = mkglobal(asmname ? asmname : name, linkage == LINKNONE && !asmname); + if (kind == DECLFUNC || linkage != LINKNONE || sc & SCSTATIC) { + if (asmname) + name = asmname; + d->value = mkglobal(name, linkage == LINKNONE && !asmname); + d->asmname = asmname; + } return d; } @@ -140,13 +140,6 @@ mkglobal(char *name, bool private) return v; } -char * -globalname(struct value *v) -{ - assert(v->kind == VALUE_GLOBAL && !v->id); - return v->u.name; -} - struct value * mkintconst(unsigned long long n) { |