shithub: scc

Download patch

ref: 384853dbfb1e264e360d552e96c225028e975fd7
parent: 0358d9db141b455cdf6904df1f3a4ef3f317c286
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 22 04:45:46 EST 2017

[cc1] Use ns from dangling symbol in popctx()

We don't know where popctx() is going to be called and we cannot
be sure that the namespace wasn't changed.

--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -105,7 +105,7 @@
 popctx(void)
 {
 	Symbol *next, *sym;
-	int dangling = 0;
+	int ns, dangling = 0;
 
 	/*
 	 * we have to be careful before popping the current
@@ -120,6 +120,7 @@
 	 */
 	if ((yytoken == IDEN || yytoken == TYPEIDEN) &&
 	    yylval.sym->ctx == curctx) {
+		ns = yylval.sym->ns;
 		dangling = 1;
 	}
 
@@ -148,7 +149,7 @@
 	}
 
 	if (dangling) {
-		yylval.sym = lookup(namespace, yytext, ALLOC);
+		yylval.sym = lookup(ns, yytext, ALLOC);
 		yytoken = yylval.sym->token;
 	}
 }