ref: dcbb7393e11a24768718b157462f5ab97ae6ed8e
parent: eaa85a83fce66986a894cda17722072840a392d9
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jul 4 17:47:00 EDT 2017
[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.
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -126,11 +126,16 @@
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);