From patchwork Tue Dec 11 22:42:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 205327 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]) by ozlabs.org (Postfix) with SMTP id 058462C0091 for ; Wed, 12 Dec 2012 09:43:04 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355870585; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=RLpVZTL vWwvsJ4vvnAxoEXo50Ss=; b=P1E7sMLp1b99mXQrH8h8z7P26Nu6+Qd53TELV3N uBxKZB9Vbi3dJ4Z40u6GadzObEV8cUVjaXqhyCRiQAIwFen2iB2p5HD1FIjWh1kA z6NUdI07cPmrKXpxiK88NFGCP71v0b9dj3XdoEq1C6+ZnevxTB1ynhxzRZSvGUn4 FrWI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=g17I+YRD6yj9aaRndZp4gtHquzTkE1J8Mx9Oj3TUTZKqZJp0CV2wWmOymc+UGI fyY5GH4X0qQ8w4TDYA1h4zPdA4XuZ+NT3slAU2ePIZ0U/g1Wr9ZfN4uTnIpsnBjO fKQSJ+EEn2SH6NHeSMb2PxbZliEf4Q4ZcLlVYPanhEXNw=; Received: (qmail 19713 invoked by alias); 11 Dec 2012 22:42:37 -0000 Received: (qmail 19592 invoked by uid 22791); 11 Dec 2012 22:42:36 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 22:42:26 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBMgQ35007758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 Dec 2012 17:42:26 -0500 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBBMgPfN008657 for ; Tue, 11 Dec 2012 17:42:26 -0500 Message-ID: <50C7B6D1.8040809@redhat.com> Date: Tue, 11 Dec 2012 17:42:25 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/54883 (link conflict with enum in anon namespace) 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 Enums in anonymous namespace should get anon visibility just like classes. Tested x86_64-pc-linux-gnu, applying to 4.6, 4.7 and trunk. commit ebb0d2ecbf7717afcb45f52ab7d7a0d68ae2157b Author: Jason Merrill Date: Tue Dec 11 16:34:24 2012 -0500 PR c++/54883 * decl2.c (min_vis_r): Handle anon visibility for enums. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index fd54cac..c5de37e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1926,16 +1926,15 @@ min_vis_r (tree *tp, int *walk_subtrees, void *data) { *walk_subtrees = 0; } - else if (CLASS_TYPE_P (*tp)) + else if (TAGGED_TYPE_P (*tp) + && !TREE_PUBLIC (TYPE_MAIN_DECL (*tp))) { - if (!TREE_PUBLIC (TYPE_MAIN_DECL (*tp))) - { - *vis_p = VISIBILITY_ANON; - return *tp; - } - else if (CLASSTYPE_VISIBILITY (*tp) > *vis_p) - *vis_p = CLASSTYPE_VISIBILITY (*tp); + *vis_p = VISIBILITY_ANON; + return *tp; } + else if (CLASS_TYPE_P (*tp) + && CLASSTYPE_VISIBILITY (*tp) > *vis_p) + *vis_p = CLASSTYPE_VISIBILITY (*tp); return NULL; } diff --git a/gcc/testsuite/g++.dg/abi/anon1.C b/gcc/testsuite/g++.dg/abi/anon1.C new file mode 100644 index 0000000..c45917a --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/anon1.C @@ -0,0 +1,5 @@ +// PR c++/54883 + +namespace { enum E { E1 }; } void f(E e) { } + +// { dg-final { scan-assembler-not "globl" } }