[hackers] [scc] [cc1] Fix install() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 26 Feb 2017 12:07:49 +0100 (CET)

commit baebb5ab3963d5383344290a1d4df0c29cf967b6
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sun Feb 26 11:59:54 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_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
_AT_@ -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
_AT_@ -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
_AT_@ -110,3 +110,4 @@
 0117-pointarith.c
 0118-voidmain.c
 0119-macrostr.c
+0120-funpar.c
Received on Sun Feb 26 2017 - 12:07:49 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 26 2017 - 12:12:24 CET