[hackers] [scc] [cc1] Fix prototype declaration || Roberto E. Vargas Caballero
commit 487793616fd6c125f87cfa8bd3e477b66e34875a
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Feb 15 08:58:45 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Feb 15 09:01:43 2017 +0100
[cc1] Fix prototype declaration
It is not needed to free the parameters of a function anymore in
decl(), because this work is already done in popctx(), although
it was harmless, since popcxt() was setting the pointer to NULL.
The main problem was this piece of code:
expect(';');
curfun = ocurfun;
Expect(';') was called before setting curfun properly, and it
means that the old value of curfun was used in expect,
which caused that several things were freed twice.
diff --git a/cc1/decl.c b/cc1/decl.c
index 6fc1765..f321d28 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -873,10 +873,8 @@ decl(void)
for (p = sym->u.pars; p && *p; ++p)
(*p)->flags |= SUSED;
popctx();
- expect(';');
- free(sym->u.pars);
- sym->u.pars = NULL;
curfun = ocurfun;
+ expect(';');
return;
}
if (sym->type->prop & TK_R) {
_AT_@ -901,8 +899,6 @@ decl(void)
compound(NULL, NULL, NULL);
popctx();
emit(OEFUN, NULL);
- free(sym->u.pars);
- sym->u.pars = NULL;
flushtypes();
curfun = ocurfun;
}
diff --git a/tests/execute/0111-doubledef.c b/tests/execute/0111-doubledef.c
new file mode 100644
index 0000000..612ffd1
--- /dev/null
+++ b/tests/execute/0111-doubledef.c
_AT_@ -0,0 +1,9 @@
+int foo(void);
+int foo(void);
+#define FOO 0
+
+int
+main()
+{
+ return FOO;
+}
diff --git a/tests/execute/scc-tests.lst b/tests/execute/scc-tests.lst
index 227e054..a73bd14 100644
--- a/tests/execute/scc-tests.lst
+++ b/tests/execute/scc-tests.lst
_AT_@ -101,3 +101,4 @@
0108-bug.c
0109-struct.c
0110-typedefcast.c
+0111-doubledef.c
Received on Wed Feb 15 2017 - 09:02:36 CET
This archive was generated by hypermail 2.3.0
: Wed Feb 15 2017 - 09:12:28 CET