scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit f05018e00e87781fe6bc927ba1b87ef8c8dc723f
parent ee745a15aaf58a70f4dd922e610c665d030f30a0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  4 Jul 2017 21:47:00 +0200

[cc1] Avoid warning about not used in fields

The current code was giving the warning error for any symbol
not in CPP namespace, even for struct fields. In this case
a switch with only two cases make easier the code.

Diffstat:
Mcc1/symbol.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -126,11 +126,16 @@ killsym(Symbol *sym) if (sym->ns == NS_TAG) sym->type->prop &= ~TDEFINED; unlinkhash(sym); - if ((name = sym->name) != NULL && sym->ns != NS_CPP) { - if ((f & (SUSED|SGLOBAL|SDECLARED)) == SDECLARED) - warn("'%s' defined but not used", name); - if ((f & SDEFINED) == 0 && sym->ns == NS_LABEL) - errorp("label '%s' is not defined", name); + if ((name = sym->name) != NULL) { + switch (sym->ns) { + case NS_LABEL: + if ((f & SDEFINED) == 0) + errorp("label '%s' is not defined", name); + case NS_IDEN: + if ((f & (SUSED|SGLOBAL|SDECLARED)) == SDECLARED) + warn("'%s' defined but not used", name); + break; + } } free(name); free(sym);