From patchwork Fri Jan 13 17:50:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 135944 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 45939B6EFE for ; Sat, 14 Jan 2012 04:50:30 +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=1327081830; h=Comment: DomainKey-Signature:Received: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=DenAlhz 2UieUKpGi44KjeQEYbM0=; b=s7EKuefzsC4LAJRd/CvwuYnSEfmpAk1rO91sJAu 6ULeKbuIHPXP/xEGFJjMXpYqIdy/arnbKxB6aqNiAf8pZd5MIQTe3Y0Jn0SC8pxl NQ3t0n1pZmNofiuyvmckFc2M9g0hySWzdulFfCOieD7gDj3aGrBtk+mp2RGuxgAQ U5L0= 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: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=ORNb+FCvGWUYHQs/FUKR46zhyecgCQGesyb0yqJ7e5HgvbKeS4BExgLQ6JuJ2k VOWunXDWkQitNAIWMa7A+gA7ve38azVY7n4lU/fNxcSKYHTMHsK3gZSC1z0j4NF9 FiLRQUta6XDwNHBswdc3mAaCv7oIlgJeQ4GP+RnsAnctg=; Received: (qmail 16036 invoked by alias); 13 Jan 2012 17:50:25 -0000 Received: (qmail 16028 invoked by uid 22791); 13 Jan 2012 17:50:24 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Fri, 13 Jan 2012 17:50:11 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0DHoBVr027675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Jan 2012 12:50:11 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0DHoBX0002151 for ; Fri, 13 Jan 2012 12:50:11 -0500 Received: from [0.0.0.0] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0DHoAoc020788 for ; Fri, 13 Jan 2012 12:50:10 -0500 Message-ID: <4F106ED1.7010505@redhat.com> Date: Fri, 13 Jan 2012 12:50:09 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51813 (visibility of template instantiation) 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 For PR 35688 I fixed the compiler to reduce the visibility of a template instantiation based on the visibility of its template arguments. As a result of this, we seem to have started marking some external symbols as .hidden because: 1) One of the template arguments is hidden, so the instantiation is as well. 2) The template has DECL_VISIBILITY_SPECIFIED because it is inside a namespace with a visibility attribute. 3) default_binds_local_p_1 decides that a decl with explicit non-default visibility binds locally, so it gets a .hidden directive. The issue here is that there is no explicit non-default visibility, so we should clear DECL_VISIBILITY_SPECIFIED when reducing the visibility of a declaration. Tested x86_64-pc-linux-gnu, applying to trunk. commit 5b39abcbdeb088fe7c19c7ff1a280ca4f7876366 Author: Jason Merrill Date: Fri Jan 13 12:39:40 2012 -0500 PR c++/51813 * decl2.c (constrain_visibility): Clear DECL_VISIBILITY_SPECIFIED when reducing the visibility. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 05f4b42..0cde6c6 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1984,6 +1984,8 @@ constrain_visibility (tree decl, int visibility, bool tmpl) && (tmpl || !DECL_VISIBILITY_SPECIFIED (decl))) { DECL_VISIBILITY (decl) = (enum symbol_visibility) visibility; + /* This visibility was not specified. */ + DECL_VISIBILITY_SPECIFIED (decl) = false; } } diff --git a/gcc/testsuite/g++.dg/ext/visibility/template9.C b/gcc/testsuite/g++.dg/ext/visibility/template9.C new file mode 100644 index 0000000..d160846 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/template9.C @@ -0,0 +1,14 @@ +// PR c++/51813 +// { dg-options -fvisibility=hidden } +// { dg-final { scan-assembler-not "hidden\\s+_ZN1N1fI1AEEvT" } } + +struct A { }; +namespace N __attribute((visibility("default"))) { + template void f(T) { } + extern template void f(A); +} + +int main() +{ + N::f(A()); +}