This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR42320


This fixes the remaining link errors with thunks and lto for
SPEC2006.  The issue is that the C++ FE neither sets TREE_STATIC
nor DECL_EXTERNAL on the thunk function and so we discard it
as non-prevailing.  Fixed with the following - in the end the
C++ FE should probably be fixed (and we should get a verifier
to force sane linkage flags).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-12-11  Richard Guenther  <rguenther@suse.de>

	PR lto/42320
	* lto-symtab.c (lto_symtab_resolve_can_prevail_p): Properly
	detect non-prevailing decls.

	* g++.dg/lto/20091210-1_0.h: New testcase.
	* g++.dg/lto/20091210-1_0.C: Likewise.
	* g++.dg/lto/20091210-1_1.C: Likewise.

Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c	(revision 155154)
--- gcc/lto-symtab.c	(working copy)
*************** lto_symtab_resolve_replaceable_p (lto_sy
*** 371,377 ****
  static bool
  lto_symtab_resolve_can_prevail_p (lto_symtab_entry_t e)
  {
!   if (!TREE_STATIC (e->decl))
      return false;
  
    /* For functions we need a non-discarded body.  */
--- 371,380 ----
  static bool
  lto_symtab_resolve_can_prevail_p (lto_symtab_entry_t e)
  {
!   /* The C++ frontend ends up neither setting TREE_STATIC nor
!      DECL_EXTERNAL on virtual methods but only TREE_PUBLIC.
!      So do not reject !TREE_STATIC here but only DECL_EXTERNAL.  */
!   if (DECL_EXTERNAL (e->decl))
      return false;
  
    /* For functions we need a non-discarded body.  */
Index: gcc/testsuite/g++.dg/lto/20091210-1_0.h
===================================================================
*** gcc/testsuite/g++.dg/lto/20091210-1_0.h	(revision 0)
--- gcc/testsuite/g++.dg/lto/20091210-1_0.h	(revision 0)
***************
*** 0 ****
--- 1,9 ----
+ struct Base1 {
+     virtual ~Base1() {}
+ };
+ struct Base2 {
+     virtual void f() = 0;
+ };
+ struct Base : Base1, Base2 {
+     virtual void f();
+ };
Index: gcc/testsuite/g++.dg/lto/20091210-1_1.C
===================================================================
*** gcc/testsuite/g++.dg/lto/20091210-1_1.C	(revision 0)
--- gcc/testsuite/g++.dg/lto/20091210-1_1.C	(revision 0)
***************
*** 0 ****
--- 1,9 ----
+ #include "20091210-1_0.h"
+ 
+ struct Foo : Base {
+     virtual void g();
+ };
+ 
+ void Foo::g() {}
+ 
+ int main() {}
Index: gcc/testsuite/g++.dg/lto/20091210-1_0.C
===================================================================
*** gcc/testsuite/g++.dg/lto/20091210-1_0.C	(revision 0)
--- gcc/testsuite/g++.dg/lto/20091210-1_0.C	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // { dg-lto-do link }
+ #include "20091210-1_0.h"
+ void Base::f() {}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]