commit baebb5ab3963d5383344290a1d4df0c29cf967b6
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Sun Feb 26 11:59:54 2017 +0100
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Sun Feb 26 12:06:54 2017 +0100

    [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.

diff --git a/cc1/symbol.c b/cc1/symbol.c
index 3d17c2b..7f8b602 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -296,7 +296,7 @@ lookup(int ns, char *name, int alloc)
 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);
diff --git a/tests/execute/0120-funpar.c b/tests/execute/0120-funpar.c
new file mode 100644
index 0000000..7dbcbb2
--- /dev/null
+++ b/tests/execute/0120-funpar.c
@@ -0,0 +1,12 @@
+
+int
+f(int f)
+{
+       return f;
+}
+
+int
+main()
+{
+       return f(0);
+}
diff --git a/tests/execute/scc-tests.lst b/tests/execute/scc-tests.lst
index f620bff..e61424f 100644
--- 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

Reply via email to