From d06865bf070f23cafe7bf03851c5b5ac3747ed97 Mon Sep 17 00:00:00 2001 From: Dave Korn Date: Mon, 10 Jan 2011 00:33:32 +0000 Subject: [PATCH] re PR c++/47218 (C++ multiple definitions of non-virtual thunk problem) gcc/ChangeLog: PR c++/47218 * cgraphunit.c (assemble_thunk): Call resolve_unique_section. gcc/testsuite/ChangeLog: PR c++/47218 * g++.dg/other/pr47218-1.C: New test file. * g++.dg/other/pr47218.C: Likewise. * g++.dg/other/pr47218.h: New supporting header. From-SVN: r168624 --- gcc/ChangeLog | 5 ++++ gcc/cgraphunit.c | 7 ++++-- gcc/testsuite/ChangeLog | 7 ++++++ gcc/testsuite/g++.dg/other/pr47218-1.C | 10 ++++++++ gcc/testsuite/g++.dg/other/pr47218.C | 19 +++++++++++++++ gcc/testsuite/g++.dg/other/pr47218.h | 33 ++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/pr47218-1.C create mode 100644 gcc/testsuite/g++.dg/other/pr47218.C create mode 100644 gcc/testsuite/g++.dg/other/pr47218.h diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb64fa82ea8..99532478c3e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-01-10 Dave Korn + + PR c++/47218 + * cgraphunit.c (assemble_thunk): Call resolve_unique_section. + 2011-01-09 Nicola Pero PR objc/47232 diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index ec477ee920b..92e5aa95461 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1,6 +1,6 @@ /* Callgraph based interprocedural optimizations. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, + 2011 Free Software Foundation, Inc. Contributed by Jan Hubicka This file is part of GCC. @@ -1317,6 +1317,9 @@ assemble_thunk (struct cgraph_node *node) current_function_decl = thunk_fndecl; + /* Ensure thunks are emitted in their correct sections. */ + resolve_unique_section (thunk_fndecl, 0, flag_function_sections); + if (this_adjusting && targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset, virtual_value, alias)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0fa673c53c0..48aa10137b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-01-10 Dave Korn + + PR c++/47218 + * g++.dg/other/pr47218-1.C: New test file. + * g++.dg/other/pr47218.C: Likewise. + * g++.dg/other/pr47218.h: New supporting header. + 2011-01-09 Nicola Pero PR objc/47232 diff --git a/gcc/testsuite/g++.dg/other/pr47218-1.C b/gcc/testsuite/g++.dg/other/pr47218-1.C new file mode 100644 index 00000000000..aeb070b0c3a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218-1.C @@ -0,0 +1,10 @@ +#include "pr47218.h" + +Foo2::~Foo2 () +{ + ((FooBaseBase1*)this)->Bar(); +} + +void Foo2::Bar() +{ +} diff --git a/gcc/testsuite/g++.dg/other/pr47218.C b/gcc/testsuite/g++.dg/other/pr47218.C new file mode 100644 index 00000000000..3056795a5fb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218.C @@ -0,0 +1,19 @@ +/* { dg-do link } */ +/* { dg-options "--save-temps" } */ +/* { dg-additional-sources "pr47218-1.C" } */ + +#include "pr47218.h" + +Foo3::~Foo3 () +{ + ((FooBaseBase1*)this)->Bar(); +} + +void Foo3::Bar() +{ +} + +int main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/pr47218.h b/gcc/testsuite/g++.dg/other/pr47218.h new file mode 100644 index 00000000000..1b07da7464c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218.h @@ -0,0 +1,33 @@ + +class FooBaseBase0 +{ +public: + virtual ~FooBaseBase0 () {} +}; + +class FooBaseBase1 +{ +public: + virtual void Bar() {} +}; + + +class FooBase: public FooBaseBase0, public FooBaseBase1 +{ +public: + virtual void Bar() {} +}; + +class Foo2: public FooBase +{ +public: + ~Foo2 (); + virtual void Bar(); +}; + +class Foo3: public FooBase +{ +public: + ~Foo3 (); + virtual void Bar(); +};