This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Don't emit_associated_thunks before expand_or_defer_fn_1 (PR c++/42256)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 Dec 2009 18:39:26 -0500
- Subject: [C++ PATCH] Don't emit_associated_thunks before expand_or_defer_fn_1 (PR c++/42256)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
emit_associated_thunks must be called after expand_or_defer_fn_1 even for
same body aliases, otherwise clone might not be yet
DECL_WEAK/DECL_COMDAT_GROUP and the clones which copy these properties from
the decl would not be weak either.
Fixed thusly, bootstrapped/regtested on x86_64-linux.
Ok for trunk?
2009-12-02 Jakub Jelinek <jakub@redhat.com>
PR c++/42256
* optimize.c (maybe_clone_body): Call emit_associated_thunks
after expand_or_defer_fn_1.
* g++.dg/inherit/thunk11.C: New test.
* g++.dg/inherit/thunk11.h: New file.
* g++.dg/inherit/thunk11-aux.cc: New file.
--- gcc/cp/optimize.c.jj 2009-12-02 20:44:36.000000000 +0100
+++ gcc/cp/optimize.c 2009-12-02 20:52:46.000000000 +0100
@@ -309,7 +309,6 @@ maybe_clone_body (tree fn)
comdat_group = cdtor_comdat_group (fns[1], fns[0]);
DECL_COMDAT_GROUP (fns[0]) = comdat_group;
}
- emit_associated_thunks (clone);
}
/* Build the delete destructor by calling complete destructor
@@ -383,7 +382,10 @@ maybe_clone_body (tree fn)
finish_function (0);
BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn);
if (alias)
- expand_or_defer_fn_1 (clone);
+ {
+ if (expand_or_defer_fn_1 (clone))
+ emit_associated_thunks (clone);
+ }
else
expand_or_defer_fn (clone);
first = false;
--- gcc/testsuite/g++.dg/inherit/thunk11.C.jj 2009-12-02 21:37:21.000000000 +0100
+++ gcc/testsuite/g++.dg/inherit/thunk11.C 2009-12-02 21:38:50.000000000 +0100
@@ -0,0 +1,11 @@
+// PR c++/42256
+// { dg-do link }
+// { dg-additional-sources "thunk11-aux.cc" }
+// { dg-options "-O2" }
+
+#include "thunk11.h"
+
+int
+main ()
+{
+}
--- gcc/testsuite/g++.dg/inherit/thunk11.h.jj 2009-12-02 21:34:14.000000000 +0100
+++ gcc/testsuite/g++.dg/inherit/thunk11.h 2009-12-02 21:29:59.000000000 +0100
@@ -0,0 +1,16 @@
+struct A
+{
+ A () {}
+ virtual ~A () {}
+};
+struct B
+{
+ B () {}
+ virtual ~B () {}
+};
+struct C : public A, public B
+{
+ virtual void foo ();
+ virtual ~C () {};
+};
+inline void C::foo () {}
--- gcc/testsuite/g++.dg/inherit/thunk11-aux.cc.jj 2009-12-02 21:37:23.000000000 +0100
+++ gcc/testsuite/g++.dg/inherit/thunk11-aux.cc 2009-12-02 21:36:09.000000000 +0100
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+#include "thunk11.h"
Jakub