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 PR43611


This fixes PR43611 where the C++ FE marks a function as necessary
due to -fkeep-inline-functions that is later nevertheless not
output.  This confuses cgraph which then first throws away the
body and then tries to inline it.

The fix is to avoid marking a function necessary if it was
instantiated externally.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for 4.5.0?

Thanks,
Richard.

2010-04-03  Richard Guenther  <rguenther@suse.de>

	PR c++/43611
	* semantics.c (expand_or_defer_fn_1): Do not keep extern
	template inline functions.

	* g++.dg/torture/pr43611.C: New testcase.

Index: gcc/testsuite/g++.dg/torture/pr43611.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr43611.C	(revision 0)
--- gcc/testsuite/g++.dg/torture/pr43611.C	(revision 0)
***************
*** 0 ****
--- 1,22 ----
+ // { dg-do compile }
+ // { dg-options "-fkeep-inline-functions" }
+ 
+ template < typename >
+ struct A {
+   void init (int);
+   A ()
+   {
+     this->init (0);
+   }
+ };
+ 
+ template < typename >
+ struct B : A < int > {
+   A < int > a;
+   B () {}
+ };
+ 
+ extern template struct A < int >;
+ extern template struct B < int >;
+ 
+ B < int > b;
Index: gcc/cp/semantics.c
===================================================================
*** gcc/cp/semantics.c	(revision 157953)
--- gcc/cp/semantics.c	(working copy)
*************** expand_or_defer_fn_1 (tree fn)
*** 3449,3455 ****
  	 this function as needed so that finish_file will make sure to
  	 output it later.  Similarly, all dllexport'd functions must
  	 be emitted; there may be callers in other DLLs.  */
!       if ((flag_keep_inline_functions && DECL_DECLARED_INLINE_P (fn))
  	  || lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn)))
  	mark_needed (fn);
      }
--- 3449,3457 ----
  	 this function as needed so that finish_file will make sure to
  	 output it later.  Similarly, all dllexport'd functions must
  	 be emitted; there may be callers in other DLLs.  */
!       if ((flag_keep_inline_functions
! 	   && DECL_DECLARED_INLINE_P (fn)
! 	   && !DECL_REALLY_EXTERN (fn))
  	  || lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn)))
  	mark_needed (fn);
      }


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