public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ patch] Fix PR 57551
@ 2013-06-07 20:17 Jan Hubicka
  2013-06-08  2:33 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2013-06-07 20:17 UTC (permalink / raw)
  To: gcc-patches, jason

Hi,
please see the PR log for details.  My symtab patch made testcase anon6.C to
fail because it tests that unused static var is output into the assembly and we
now optimize it out.

Adding attribute used however shows problem that the var suddenly becomes WEAK
and COMDAT. It seems to me that this is bug in C++ FE. Watchpointing the decl
I found that the decl is first correctly brought static by constrain_visibility
but later it is exported again by mark_decl_instantiated.

I think mark_decl_instantiated is wrong. I am not at all sure if the following
patch is proper fix though.

After this patch at least GCC agrees with clang on the testcase.

Bootstrapped/regtested x86_64-linux, OK?

Honza

	PR c++/57551
	* cp/pt.c (mark_decl_instantiated): Do not export explicit instantiations
	of anonymous namespace templates.

	* g++.dg/ext/visibility/anon6.C: Update testcase.

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 199698)
+++ cp/pt.c	(working copy)
@@ -17402,6 +17402,13 @@ mark_decl_instantiated (tree result, int
   if (TREE_ASM_WRITTEN (result))
     return;
 
+  /* For anonymous namespace we don't need to do anything.  */
+  if (decl_anon_ns_mem_p (result))
+    {
+      gcc_assert (!TREE_PUBLIC (result));
+      return;
+    }
+
   if (TREE_CODE (result) != FUNCTION_DECL)
     /* The TREE_PUBLIC flag for function declarations will have been
        set correctly by tsubst.  */
Index: testsuite/g++.dg/ext/visibility/anon6.C
===================================================================
--- testsuite/g++.dg/ext/visibility/anon6.C	(revision 199698)
+++ testsuite/g++.dg/ext/visibility/anon6.C	(working copy)
@@ -1,6 +1,8 @@
 // PR c++/33094
 // { dg-final { scan-assembler "1BIiE1cE" } }
 // { dg-final { scan-assembler-not "globl.*1BIiE1cE" } }
+// { dg-final { scan-assembler-not "comdat" } }
+// { dg-final { scan-assembler-not "weak" } }
 // { dg-final { scan-assembler-not "1CIiE1cE" } }
 
 // Test that B<int>::c is emitted as an internal symbol, and C<int>::c is
@@ -18,7 +20,7 @@ namespace
   template <typename T>
   class B
   {
-    static const T c = 0;
+    __attribute__ ((__used__)) static const T c = 0;
   };
 
   template <typename T> const T B<T>::c;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ patch] Fix PR 57551
  2013-06-07 20:17 [C++ patch] Fix PR 57551 Jan Hubicka
@ 2013-06-08  2:33 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2013-06-08  2:33 UTC (permalink / raw)
  To: Jan Hubicka, gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-08  2:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 20:17 [C++ patch] Fix PR 57551 Jan Hubicka
2013-06-08  2:33 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).