* [C++ gnu_inline] fix ICE inlining after definition and redeclaration
@ 2007-10-01 19:53 Alexandre Oliva
2007-10-01 21:42 ` Jakub Jelinek
2007-10-03 18:09 ` Jason Merrill
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Oliva @ 2007-10-01 19:53 UTC (permalink / raw)
To: gcc-patches, jason; +Cc: jakub
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
Jakub found an error in my earlier patch. If a gnu_inline function
was redeclared without a new definition, and then called, we'd ICE
when inlining it. Here's a patch that fixes it, by arranging for the
linkage flags to not be affected by mere redeclarations, only by
actual redefinitions.
Jakub offered to test it, so I haven't, other than by compiling by
hand the test included in the patch. Ok to install after Jakub
completes testing it?
:ADDPATCH c++/gnu_inline:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gcc-cp-extern-gnu-inline-fallout.patch --]
[-- Type: text/x-patch, Size: 2405 bytes --]
Index: gcc/cp/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* decl.c (duplicate_decls): Preserve linkage flags for mere
redeclarations of gnu_inline definitions.
Index: gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* g++.dg/ext/gnu-inline-global-redecl.C: New.
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c.orig 2007-09-28 00:02:33.000000000 -0300
+++ gcc/cp/decl.c 2007-10-01 16:33:10.000000000 -0300
@@ -1846,24 +1846,24 @@ duplicate_decls (tree newdecl, tree oldd
new_template = NULL_TREE;
if (DECL_LANG_SPECIFIC (newdecl) && DECL_LANG_SPECIFIC (olddecl))
{
- bool old_decl_gnu_inline;
+ bool new_redefines_gnu_inline = false;
- if ((DECL_INTERFACE_KNOWN (olddecl)
- && TREE_CODE (olddecl) == FUNCTION_DECL)
- || (TREE_CODE (olddecl) == TEMPLATE_DECL
- && TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == FUNCTION_DECL))
+ if (new_defines_function
+ && ((DECL_INTERFACE_KNOWN (olddecl)
+ && TREE_CODE (olddecl) == FUNCTION_DECL)
+ || (TREE_CODE (olddecl) == TEMPLATE_DECL
+ && (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl))
+ == FUNCTION_DECL))))
{
tree fn = olddecl;
if (TREE_CODE (fn) == TEMPLATE_DECL)
fn = DECL_TEMPLATE_RESULT (olddecl);
- old_decl_gnu_inline = GNU_INLINE_P (fn) && DECL_INITIAL (fn);
+ new_redefines_gnu_inline = GNU_INLINE_P (fn) && DECL_INITIAL (fn);
}
- else
- old_decl_gnu_inline = false;
- if (!old_decl_gnu_inline)
+ if (!new_redefines_gnu_inline)
{
DECL_INTERFACE_KNOWN (newdecl) |= DECL_INTERFACE_KNOWN (olddecl);
DECL_NOT_REALLY_EXTERN (newdecl) |= DECL_NOT_REALLY_EXTERN (olddecl);
Index: gcc/testsuite/g++.dg/ext/gnu-inline-global-redecl.C
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/g++.dg/ext/gnu-inline-global-redecl.C 2007-10-01 16:45:49.000000000 -0300
@@ -0,0 +1,19 @@
+/* Test __attribute__((gnu_inline)).
+
+ Check that we don't get out-of-line definitions for extern inline
+ gnu_inline functions, regardless of redeclaration.
+
+ */
+
+/* { dg-do link } */
+/* { dg-options "-O" } */ // such that static functions are optimized out
+
+#include "gnu-inline-common.h"
+
+decl(extern, fn)
+gnuindef(fn, 0)
+decl(extern, fn)
+
+int main () {
+ fn ();
+}
[-- Attachment #3: Type: text/plain, Size: 249 bytes --]
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ gnu_inline] fix ICE inlining after definition and redeclaration
2007-10-01 19:53 [C++ gnu_inline] fix ICE inlining after definition and redeclaration Alexandre Oliva
@ 2007-10-01 21:42 ` Jakub Jelinek
2007-10-03 18:09 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2007-10-01 21:42 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-patches, Jason Merrill
On Mon, Oct 01, 2007 at 04:52:46PM -0300, Alexandre Oliva wrote:
> Jakub found an error in my earlier patch. If a gnu_inline function
> was redeclared without a new definition, and then called, we'd ICE
> when inlining it. Here's a patch that fixes it, by arranging for the
> linkage flags to not be affected by mere redeclarations, only by
> actual redefinitions.
>
> Jakub offered to test it, so I haven't, other than by compiling by
> hand the test included in the patch. Ok to install after Jakub
> completes testing it?
Bootstrapped/regtested on x86_64-linux.
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ gnu_inline] fix ICE inlining after definition and redeclaration
2007-10-01 19:53 [C++ gnu_inline] fix ICE inlining after definition and redeclaration Alexandre Oliva
2007-10-01 21:42 ` Jakub Jelinek
@ 2007-10-03 18:09 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2007-10-03 18:09 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-patches, jakub
OK.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-03 18:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-01 19:53 [C++ gnu_inline] fix ICE inlining after definition and redeclaration Alexandre Oliva
2007-10-01 21:42 ` Jakub Jelinek
2007-10-03 18:09 ` Jason Merrill
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).