* [PATCH] Fix PR c/8518
@ 2002-11-16 17:24 Eric Botcazou
2002-11-19 15:00 ` Richard Henderson
0 siblings, 1 reply; 8+ messages in thread
From: Eric Botcazou @ 2002-11-16 17:24 UTC (permalink / raw)
To: gcc-patches
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(); }
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-16 17:24 [PATCH] Fix PR c/8518 Eric Botcazou
@ 2002-11-19 15:00 ` Richard Henderson
2002-11-19 15:40 ` Geoff Keating
2002-11-20 3:00 ` Eric Botcazou
0 siblings, 2 replies; 8+ messages in thread
From: Richard Henderson @ 2002-11-19 15:00 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On Sun, Nov 17, 2002 at 02:23:19AM +0100, Eric Botcazou wrote:
> ... 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(); }
Incidentally, this seems like error material. The redefinition of an
extern inline function should be neither static nor inline itself.
> PR c/8518
> * c-decl.c (duplicate_decls): Outline the second definition
> of an extern inline function in all cases.
> * gcc.c-torture/compile/20021117-1.c: New test
> * gcc.c-torture/compile/20021117-2.c: New test
I guess this is ok though.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-19 15:00 ` Richard Henderson
@ 2002-11-19 15:40 ` Geoff Keating
2002-11-19 15:51 ` Richard Henderson
2002-11-20 3:00 ` Eric Botcazou
1 sibling, 1 reply; 8+ messages in thread
From: Geoff Keating @ 2002-11-19 15:40 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc-patches
Richard Henderson <rth@redhat.com> writes:
> On Sun, Nov 17, 2002 at 02:23:19AM +0100, Eric Botcazou wrote:
> > ... 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(); }
>
> Incidentally, this seems like error material. The redefinition of an
> extern inline function should be neither static nor inline itself.
I'd argue that the redefinition of any function should be an error.
--
- Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-19 15:40 ` Geoff Keating
@ 2002-11-19 15:51 ` Richard Henderson
2002-11-19 16:13 ` Geoff Keating
0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2002-11-19 15:51 UTC (permalink / raw)
To: Geoff Keating; +Cc: gcc-patches
On Tue, Nov 19, 2002 at 03:40:45PM -0800, Geoff Keating wrote:
> I'd argue that the redefinition of any function should be an error.
extern inline is special, since it means "this function will
be defined out of line somewhere else".
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-19 15:51 ` Richard Henderson
@ 2002-11-19 16:13 ` Geoff Keating
2002-11-19 16:15 ` Richard Henderson
0 siblings, 1 reply; 8+ messages in thread
From: Geoff Keating @ 2002-11-19 16:13 UTC (permalink / raw)
To: rth; +Cc: gcc-patches
> Date: Tue, 19 Nov 2002 15:51:36 -0800
> From: Richard Henderson <rth@redhat.com>
> Cc: gcc-patches@gcc.gnu.org
> Mail-Followup-To: Richard Henderson <rth@redhat.com>,
> Geoff Keating <geoffk@geoffk.org>, gcc-patches@gcc.gnu.org
> Content-Disposition: inline
> User-Agent: Mutt/1.4i
> X-OriginalArrivalTime: 19 Nov 2002 23:51:40.0507 (UTC) FILETIME=[9B192AB0:01C29026]
>
> On Tue, Nov 19, 2002 at 03:40:45PM -0800, Geoff Keating wrote:
> > I'd argue that the redefinition of any function should be an error.
>
> extern inline is special, since it means "this function will
> be defined out of line somewhere else".
The way that ISO C handles this is that you write
inline int foo(void) { return 1; } // in header
extern int foo(void); // in .c
and the compiler's supposed to produce an out-of-line copy of the
function.
--
- Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-19 16:13 ` Geoff Keating
@ 2002-11-19 16:15 ` Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2002-11-19 16:15 UTC (permalink / raw)
To: Geoff Keating; +Cc: gcc-patches
On Tue, Nov 19, 2002 at 04:13:31PM -0800, Geoff Keating wrote:
> The way that ISO C handles this is that you write
>
> inline int foo(void) { return 1; } // in header
> extern int foo(void); // in .c
>
> and the compiler's supposed to produce an out-of-line copy of the
> function.
That is indeed a better solution. Doesn't help with the
existing GCC extension though. :-(
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-19 15:00 ` Richard Henderson
2002-11-19 15:40 ` Geoff Keating
@ 2002-11-20 3:00 ` Eric Botcazou
2002-11-20 9:24 ` Richard Henderson
1 sibling, 1 reply; 8+ messages in thread
From: Eric Botcazou @ 2002-11-20 3:00 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc-patches
> > PR c/8518
> > * c-decl.c (duplicate_decls): Outline the second definition
> > of an extern inline function in all cases.
> > * gcc.c-torture/compile/20021117-1.c: New test
> > * gcc.c-torture/compile/20021117-2.c: New test
>
> I guess this is ok though.
Applied. OK for the branch too ?
--
Eric Botcazou
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix PR c/8518
2002-11-20 3:00 ` Eric Botcazou
@ 2002-11-20 9:24 ` Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2002-11-20 9:24 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On Wed, Nov 20, 2002 at 12:00:57PM +0100, Eric Botcazou wrote:
> Applied. OK for the branch too ?
Once it's open.
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-11-20 17:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-16 17:24 [PATCH] Fix PR c/8518 Eric Botcazou
2002-11-19 15:00 ` Richard Henderson
2002-11-19 15:40 ` Geoff Keating
2002-11-19 15:51 ` Richard Henderson
2002-11-19 16:13 ` Geoff Keating
2002-11-19 16:15 ` Richard Henderson
2002-11-20 3:00 ` Eric Botcazou
2002-11-20 9:24 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).