diff options
author | Jason Merrill <jason@redhat.com> | 2014-02-25 13:54:48 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-02-25 13:54:48 -0500 |
commit | 6e6eaecc6ab7c461f13e7a76fa3ab85b721242e8 (patch) | |
tree | 7b8ab05926a8a8c7bc52d0bd9e8bf519ef46d1ab /gcc | |
parent | d808e92ea950feeba41a5019ada7cddbbe0a5ed7 (diff) | |
download | gcc-6e6eaecc6ab7c461f13e7a76fa3ab85b721242e8.zip gcc-6e6eaecc6ab7c461f13e7a76fa3ab85b721242e8.tar.gz gcc-6e6eaecc6ab7c461f13e7a76fa3ab85b721242e8.tar.bz2 |
re PR lto/53808 (Undefined symbol when building a library with lto)
PR lto/53808
* class.c (clone_function_decl): Call note_vague_linkage_fn for
defaulted virtual dtor.
From-SVN: r208153
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/class.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/devirt4.C | 16 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f63b8e..393b213 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-02-25 Jason Merrill <jason@redhat.com> + PR lto/53808 + * class.c (clone_function_decl): Call note_vague_linkage_fn for + defaulted virtual dtor. + DR 1286 PR c++/60328 * pt.c (get_underlying_template): Fix equivalence calculation. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 97a1cc2..e861e4d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4582,6 +4582,10 @@ clone_function_decl (tree fn, int update_method_vec_p) destructor. */ if (DECL_VIRTUAL_P (fn)) { + if (DECL_DEFAULTED_FN (fn) && flag_devirtualize) + /* Make sure the destructor gets synthesized so that it can be + inlined after devirtualization. */ + note_vague_linkage_fn (fn); clone = build_clone (fn, deleting_dtor_identifier); if (update_method_vec_p) add_method (DECL_CONTEXT (clone), clone, NULL_TREE); diff --git a/gcc/testsuite/g++.dg/opt/devirt4.C b/gcc/testsuite/g++.dg/opt/devirt4.C new file mode 100644 index 0000000..5a24eec --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/devirt4.C @@ -0,0 +1,16 @@ +// PR lto/53808 +// Devirtualization + inlining should produce a non-virtual +// call to ~foo. +// { dg-options "-O -fdevirtualize" } +// { dg-final { scan-assembler "_ZN3fooD2Ev" } } + +struct foo { + virtual ~foo(); +}; +struct bar : public foo { + virtual void zed(); +}; +void f() { + foo *x(new bar); + delete x; +} |