[PATCH] Fix PR c/8518
Eric Botcazou
ebotcazou@libertysurf.fr
Sat Nov 16 17:24:00 GMT 2002
Hi,
This is a high-priority PR, regression from 3.0.x on gcc-3_2-branch and
mainline. The compiler segfaults when building the initial CFG, but I think
the problem comes from the front-end: the compiler gets confused because of
the redefinition of an extern inline function:
extern int inline bar () { return 0; }
static int inline bar () { return foo(); }
bar() is deferred twice and is expanded twice by expand_deferred_fns() at the
end of the file.
On the contrary, in the following slighly modified situation:
extern int inline bar () { return 0; }
static int baz () { return bar(); }
static int inline bar () { return foo(); }
bar() is deferred only once because the compiler authoritatively outlines the
second definition of bar(), and the first bar() is thus never expanded.
The proposed fix is to even the things, i.e to authoritatively outline the
second definition of bar() in the first situation too. Bootstrapped/regtested
on i586-redhat-linux-gnu (c,c++,objc,f77).
Ok for mainline and for gcc-3_2-branch when it reopens ?
--
Eric Botcazou
2002-11-17 Eric Botcazou <ebotcazou@libertysurf.fr>
PR c/8518
* c-decl.c (duplicate_decls): Outline the second definition
of an extern inline function in all cases.
2002-11-17 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20021117-1.c: New test
* gcc.c-torture/compile/20021117-2.c: New test
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.353
diff -c -r1.353 c-decl.c
*** c-decl.c 10 Nov 2002 16:24:24 -0000 1.353
--- c-decl.c 16 Nov 2002 21:59:43 -0000
***************
*** 1474,1482 ****
inline, make sure we emit debug info for the inline before we
throw it away, in case it was inlined into a function that hasn't
been written out yet. */
! if (new_is_definition && DECL_INITIAL (olddecl) && TREE_USED
(olddecl))
{
! (*debug_hooks->outlining_inline_function) (olddecl);
/* The new defn must not be inline. */
DECL_INLINE (newdecl) = 0;
--- 1474,1483 ----
inline, make sure we emit debug info for the inline before we
throw it away, in case it was inlined into a function that hasn't
been written out yet. */
! if (new_is_definition && DECL_INITIAL (olddecl))
{
! if (TREE_USED (olddecl))
! (*debug_hooks->outlining_inline_function) (olddecl);
/* The new defn must not be inline. */
DECL_INLINE (newdecl) = 0;
--- /dev/null Thu Apr 11 16:25:15 2002
+++ gcc.c-torture/compile/20021117-1.c Sun Nov 17 02:21:30 2002
@@ -0,0 +1,9 @@
+/* PR c/8518 */
+/* Contributed by Volker Reichelt. */
+
+/* Verify that GCC doesn't get confused by the
+ redefinition of an extern inline function. */
+
+extern int inline foo () { return 0; }
+extern int inline bar () { return 0; }
+static int inline bar () { return foo(); }
--- /dev/null Thu Apr 11 16:25:15 2002
+++ gcc.c-torture/compile/20021117-2.c Sun Nov 17 02:21:57 2002
@@ -0,0 +1,9 @@
+/* PR c/8518 */
+/* Contributed by Volker Reichelt. */
+
+/* Verify that GCC doesn't get confused by the
+ redefinition of an extern inline function. */
+
+extern int inline foo () { return 0; }
+extern int inline bar () { return 0; }
+static int bar () { return foo(); }
More information about the Gcc-patches
mailing list