ref: f6970279c96254b3407c1d0f2ade3342c26b87b6
parent: 510b4fad0f6339b629f25bad6b02037ae4b7d8af
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 8 14:15:13 EDT 2015
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.
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -340,7 +340,7 @@
warn("'%s' redefined", yytext);
free(sym->u.s);
} else {
- sym = lookup(NS_CPP, yytext);
+ sym = install(NS_CPP, sym);
sym->flags |= ISDECLARED;
}
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -431,7 +431,8 @@
* 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)
--- a/cc1/tests/test015.c
+++ b/cc1/tests/test015.c
@@ -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
@@ -30,7 +30,6 @@
????
*/
-#line 1
typedef struct s s;
struct s {
@@ -42,9 +41,12 @@
} s;
} s2;
+#define s s
+
int
main(void)
{
+#undef s
goto s;
struct s s;
{