From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13371 invoked by alias); 7 Jun 2013 20:17:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13360 invoked by uid 89); 7 Jun 2013 20:17:32 -0000 X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 07 Jun 2013 20:17:32 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id DFA6B54301D; Fri, 7 Jun 2013 22:17:29 +0200 (CEST) Date: Fri, 07 Jun 2013 20:17:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: [C++ patch] Fix PR 57551 Message-ID: <20130607201729.GD29599@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-SW-Source: 2013-06/txt/msg00433.txt.bz2 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::c is emitted as an internal symbol, and C::c is @@ -18,7 +20,7 @@ namespace template class B { - static const T c = 0; + __attribute__ ((__used__)) static const T c = 0; }; template const T B::c;