Bugzilla – Bug 244
[llvm-gcc] Error when an implicitly external function is re-declared as static
Last modified: 2004-11-27 18:08:50
You need to log in before you can comment on or make changes to this bug.
The attached code produces a warning with GCC but otherwise produces a single function defintion. With LLVM GCC, the attached code generates one function declaration (but no function definition) and one internal function (which is defined).
Created an attachment (id=81) [details] C code to reproduce the problem To reproduce, use the following: llvm-gcc -S test.c -o test.ll With GCC 3.3, we get the warning: test.c:10: warning: `two' was declared implicitly `extern' and later `static' test.c:4: warning: previous declaration of `two'
Created an attachment (id=82) [details] Incorrect output generated by the test case.
This bug blocks the correct functioning of the espresso Malloc Benchmark.
I _love_ C! :)
FWIW, this is probably related to Bug 232.
Here's another broken testcase: int one(int a) { two(a, 5); return 0; } static void two(int a, int b) {} ... in this case, the body of 'two' never gets emitted. -Chris
Fixed. Here's the (one token) patch: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040216/011969.html Testcase here: test/Regression/CFrontend/2004-02-20-StaticRedeclare.c.tr It turns out that the second "bad case" that I included in this bug is actually erroneous C code, so it's not a suprise we don't handle it. :) -Chris
*** Bug 232 has been marked as a duplicate of this bug. ***
I'm reopening this bug. There seems to be no way to fix both this bug and Bug 276 at the same time. It appears that the root cause of this bug is internal to the GCC front-end. This should be revisited for 1.3 when we have hopefully sync'd up with GCC CVS more. -Chris
Note that this bug is preventing us from being able to compile 134.perl. There the situation looks like this: ----- static int func(); void bar() { int func(); foo(func); } static int func(char** A, char ** B) {} --------- Two prototypes with different names are created for 'func'. -Chris
I'm curious. How are the names of the two "func" functions different? Or, did you mean with different signatures?
The C front-end (buggily) gave the prototype one name ".func_1" and the body another ".func_2", which the linker, understandably, does not link up. This is a CFE bug. -Chris
Fixed. Testcase here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041122/021383.html Patch here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041122/021384.html -Chris