commit 487793616fd6c125f87cfa8bd3e477b66e34875a
parent 2415117f72d9b53f10e6ced86efc9a34f527ed15
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 15 Feb 2017 08:58:45 +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.
Diffstat:
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -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) {
@@ -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
@@ -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
@@ -101,3 +101,4 @@
0108-bug.c
0109-struct.c
0110-typedefcast.c
+0111-doubledef.c