This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/61687 (extra errors with -O2)
- From: Jason Merrill <jason at redhat dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 29 Jul 2014 10:48:24 -0400
- Subject: Re: C++ PATCH for c++/61687 (extra errors with -O2)
- Authentication-results: sourceware.org; auth=none
- References: <53BEE83C dot 2000700 at redhat dot com> <20140717122316 dot GA19997 at atrey dot karlin dot mff dot cuni dot cz> <53D18535 dot 9040006 at redhat dot com> <20140724233617 dot GC25691 at kam dot mff dot cuni dot cz> <53D28200 dot 6060002 at redhat dot com> <20140728112227 dot GA15665 at kam dot mff dot cuni dot cz>
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.
Jason
commit 273eacac43a4bdeda9c4838dc05c40615d6a5f80
Author: Jason Merrill <jason@redhat.com>
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_NOT_REALLY_EXTERN (fn) = 1;
DECL_DECLARED_INLINE_P (fn) = 1;
+ 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));
/* Restore PROCESSING_TEMPLATE_DECL. */