shithub: scc

Download patch

ref: 51850809dec3daafd0da16366e404df08ae4f44e
parent: 0bab8ee83c31cd1512c33b85a3825e1cd87c9b85
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Feb 26 06:59:54 EST 2017

[cc1] Fix install()

Install() was only checking if the symbol to install was already
defined before creating a new symbol, but it fails in the case of
functions, where you can have a parameter with the same name than
the function. In this case the parameter is installed before the
function symbol is installed.

--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -296,7 +296,7 @@
 Symbol *
 install(int ns, Symbol *sym)
 {
-	if (sym->flags & SDECLARED) {
+	if (sym->flags & SDECLARED || sym->ctx != curctx) {
 		if (sym->ctx == curctx && ns == sym->ns)
 			return NULL;
 		sym = newsym(ns, sym->name);
--- /dev/null
+++ b/tests/execute/0120-funpar.c
@@ -1,0 +1,12 @@
+
+int
+f(int f)
+{
+	return f;
+}
+
+int
+main()
+{
+	return f(0);
+}
--- a/tests/execute/scc-tests.lst
+++ b/tests/execute/scc-tests.lst
@@ -110,3 +110,4 @@
 0117-pointarith.c
 0118-voidmain.c
 0119-macrostr.c
+0120-funpar.c