[hackers] [scc] Fix define() || Roberto E. Vargas Caballero
commit f6970279c96254b3407c1d0f2ade3342c26b87b6
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 8 18:15:13 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Sep 8 18:15:13 2015 +0200
Fix define()
After the last symbol table rewritten, define in cpp was not working,
because the semantic of the table was totally different. Symbols are
not ever declared with lookup(), a explicit call to install is needed.
For the same reason, it is also necesary check in iden() if we are in
cppmode, because in other case we can call to nextsym() in all the
symbols defined in the preprocessor.
diff --git a/cc1/cpp.c b/cc1/cpp.c
index 0516c65..2c4587f 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -340,7 +340,7 @@ define(void)
warn("'%s' redefined", yytext);
free(sym->u.s);
} else {
- sym = lookup(NS_CPP, yytext);
+ sym = install(NS_CPP, sym);
sym->flags |= ISDECLARED;
}
diff --git a/cc1/lex.c b/cc1/lex.c
index 06364ca..501e0d4 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -431,7 +431,8 @@ iden(void)
* it is not a correct macro call, so try to find
* another definition.
*/
- sym = nextsym(sym, namespace);
+ if (lexmode != CPPMODE)
+ sym = nextsym(sym, namespace);
}
yylval.sym = sym;
if (sym->flags & ISCONSTANT)
diff --git a/cc1/tests/test015.c b/cc1/tests/test015.c
index 4bfb46a..ba23675 100644
--- a/cc1/tests/test015.c
+++ b/cc1/tests/test015.c
_AT_@ -2,7 +2,7 @@
name: TEST015
description: Stress namespace mechanism
output:
-test015.c:25: error: label 's' already defined
+test015.c:60: error: label 's' already defined
S8 s2
(
M9 I s
_AT_@ -30,7 +30,6 @@ L2
????
*/
-#line 1
typedef struct s s;
struct s {
_AT_@ -42,9 +41,12 @@ struct s {
} s;
} s2;
+#define s s
+
int
main(void)
{
+#undef s
goto s;
struct s s;
{
Received on Tue Sep 08 2015 - 18:17:46 CEST
This archive was generated by hypermail 2.3.0
: Tue Sep 08 2015 - 18:24:11 CEST