This is the mail archive of the 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]

Re: C++ PATCH for c++/61687 (extra errors with -O2)

On 07/28/2014 07:22 AM, Jan Hubicka wrote:
We decide what we can devirtualize in can_refer_decl_in_current_unit_p.
So the problem is that we have functions that should be COMDAT but they are not
because we decide to not produce their body (believing it is not reachable).  Can't
we arrange them havin a special flag (CAN_NOT_REFFER) or perhaps just COMDAT flag?

Yes, I think we can just set DECL_COMDAT. This fixes the LTO problem from my previous mail.


commit 273eacac43a4bdeda9c4838dc05c40615d6a5f80
Author: Jason Merrill <>
Date:   Tue Jul 29 10:21:45 2014 -0400

    	PR c++/61659
    	* method.c (implicitly_declare_fn): Set DECL_COMDAT.  Determine
    	linkage after setting the appropriate flags.

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index e5fa0c1..f86a214 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1798,8 +1798,6 @@ implicitly_declare_fn (special_function_kind kind, tree type,
   DECL_ARGUMENTS (fn) = this_parm;
   grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
-  set_linkage_according_to_type (type, fn);
-  rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
   DECL_IN_AGGR_P (fn) = 1;
   DECL_ARTIFICIAL (fn) = 1;
   DECL_DEFAULTED_FN (fn) = 1;
@@ -1811,6 +1809,9 @@ implicitly_declare_fn (special_function_kind kind, tree type,
   DECL_EXTERNAL (fn) = true;
+  DECL_COMDAT (fn) = 1;
+  set_linkage_according_to_type (type, fn);
+  rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
   gcc_assert (!TREE_USED (fn));

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