From patchwork Fri Jun 7 20:17:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 249813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 529072C00AB for ; Sat, 8 Jun 2013 06:17:39 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=LysD27HBcD0NvwtRu/baWTgPuDQpLn5LBxprjcglmOiYpT6NorcE5 Ae3ba2jH5ajR0uSk0P7oJ2B2uGVNKQ+CU+mJL1/WeIjsl8XAim7SrkTenTXcaOuS ccptdWWK8qNVOZPB37bb+YTBYLSV+7sLY7lIqMSHQrPLjmEEeqnBNI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=SlANldNSasA327hCjueUY5FvoeE=; b=yL6ZCQkg/pfRdCUHxy/n 1Cg+297ltT40Jad8wEAytAOoJfLm6X5+VCFI3qN+slc7AtnXyTTlTepEP2q1utUK NAcksAyYJBiICQbIMQ7h6Lo59clQ/p/NebiuWE/whXZDhDBkgbD3huzLk3oPiesK 35dHD8AG0yoOoruABCzwn4g= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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, 7 Jun 2013 22:17:29 +0200 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-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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;