[hackers] [scc] Remove delmacro() || Roberto E. Vargas Caballero
commit b5a07a8e256269a057c0143c8f61f131d038eb44
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Sep 28 23:13:39 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Sep 28 23:17:08 2015 +0200
Remove delmacro()
Delmacro() is not needed at all, because its work is already done by
killsym, which is more generic.
diff --git a/cc1/cc1.h b/cc1/cc1.h
index 7ef0e38..997febb 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -346,7 +346,7 @@ extern Symbol *install(int ns, Symbol *sym);
extern Symbol *newsym(int ns);
extern void pushctx(void), popctx(void);
extern void ikeywords(void);
-extern void delmacro(Symbol *sym);
+extern void killsym(Symbol *sym);
extern Symbol *newlabel(void);
/* stmt.c */
diff --git a/cc1/cpp.c b/cc1/cpp.c
index e2081a7..d7939a8 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -241,7 +241,7 @@ substitute:
input->p = input->begin = begin;
if (!(sym->flags & ISDECLARED))
- delmacro(sym);
+ killsym(sym);
return 1;
}
_AT_@ -342,7 +342,7 @@ define(void)
free(sym->u.s);
} else {
sym = install(NS_CPP, sym);
- sym->flags |= ISDECLARED;
+ sym->flags |= ISDECLARED|ISSTRING;
}
namespace = NS_IDEN; /* Avoid polution in NS_CPP */
_AT_@ -357,7 +357,7 @@ define(void)
return;
delete:
- delmacro(sym);
+ killsym(sym);
}
void
_AT_@ -531,7 +531,7 @@ ifclause(int negate, int isifdef)
next();
status = (sym->flags & ISDECLARED) != 0;
if (!status)
- delmacro(sym);
+ killsym(sym);
} else {
/* TODO: catch recovery here */
if ((expr = iconstexpr()) == NULL) {
_AT_@ -614,7 +614,7 @@ undef(void)
error("no macro name given in #undef directive");
return;
}
- delmacro(yylval.sym);
+ killsym(yylval.sym);
next();
}
diff --git a/cc1/symbol.c b/cc1/symbol.c
index a5f67b0..9b07096 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -76,7 +76,7 @@ pushctx(void)
error("too much nested blocks");
}
-static void
+void
killsym(Symbol *sym)
{
short f;
_AT_@ -87,14 +87,14 @@ killsym(Symbol *sym)
free(sym->u.s);
if (sym->ns == NS_TAG)
sym->type->defined = 0;
- if ((name = sym->name) != NULL) {
- unlinkhash(sym);
+ unlinkhash(sym);
+ if ((name = sym->name) != NULL && sym->ns != NS_CPP) {
if ((f & (ISUSED|ISGLOBAL|ISDECLARED)) == ISDECLARED)
warn("'%s' defined but not used", name);
if ((f & ISDEFINED) == 0 && sym->ns == NS_LABEL)
errorp("label '%s' is not defined", name);
- free(name);
}
+ free(name);
free(sym);
}
_AT_@ -168,7 +168,6 @@ linksym(Symbol *sym)
{
Symbol *p, *prev;
- sym->flags |= ISDECLARED;
switch (sym->ns) {
case NS_CPP:
return sym;
_AT_@ -198,7 +197,6 @@ linkhash(Symbol *sym)
Symbol **h, *p, *prev;
h = &htab[hash(sym->name)];
-
for (prev = p = *h; p; prev = p, p = p->hash) {
if (p->ctx <= sym->ctx)
break;
_AT_@ -214,16 +212,14 @@ linkhash(Symbol *sym)
if (sym->ns != NS_CPP)
sym->id = newid();
+ sym->flags |= ISDECLARED;
return linksym(sym);
}
Symbol *
newsym(int ns)
{
- Symbol *sym;
-
- sym = linksym(allocsym(ns, NULL));
- return sym;
+ return linksym(allocsym(ns, NULL));
}
Symbol *
_AT_@ -253,15 +249,6 @@ lookup(int ns, char *name)
return allocsym(ns, name);
}
-void
-delmacro(Symbol *sym)
-{
- unlinkhash(sym);
- free(sym->name);
- free(sym->u.s);
- free(sym);
-}
-
Symbol *
nextsym(Symbol *sym, int ns)
{
Received on Mon Sep 28 2015 - 23:20:01 CEST
This archive was generated by hypermail 2.3.0
: Mon Sep 28 2015 - 23:24:11 CEST