From patchwork Tue Jan 22 16:04:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 214581 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 4D9422C007E for ; Wed, 23 Jan 2013 03:04:58 +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=1359475499; 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=s8Kauxj 07rtb82FuX1hMOMHDHnE=; b=AGLV0ti62LsUUrQDiGZ+7jyjzNZ/yW34pJP4kVv HBBoxunvv+LB+QCJrzVFfmarF5rYkgvcGlYuTPQLDCz4HF+wbOYLK8IZe2FvKhbg sIEdnkOsq6M9CQueXw6LSMmP5cY/P7++euuDJd/oyQvHM4LXbyJUYMYgJLMJc/Fj J2OE= 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=hIIOu5+pL3Bh37CnvJWCUneJzkqjQprUUqVFfTYL75awC3GqYhJoRhZAreUkHu A9hJ9KJkSlsb9JfBXSca4dvenDYS/KXjhCfy9NktbNtcp/59goDIWDWMC4uyq/AC CeKexARuOXGe0MNQ9pZ+bbXh/qxE8lQd0giGoAsIiWP9A=; Received: (qmail 13771 invoked by alias); 22 Jan 2013 16:04:52 -0000 Received: (qmail 13755 invoked by uid 22791); 22 Jan 2013 16:04:51 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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, 22 Jan 2013 16:04:44 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0MG4h9I028649 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Jan 2013 11:04:44 -0500 Received: from [10.3.113.46] (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0MG4ho3008088 for ; Tue, 22 Jan 2013 11:04:43 -0500 Message-ID: <50FEB89A.8060701@redhat.com> Date: Tue, 22 Jan 2013 11:04:42 -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++/56071 (wrong access error with noexcept) 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 Pushing into the right access scope isn't enough if we defer the check until after we leave the scope... Tested x86_64-pc-linux-gnu, applying to trunk. commit 31d44658775ceaedddefbeac8c7ea735be8f3576 Author: Jason Merrill Date: Tue Jan 22 10:50:53 2013 -0500 PR c++/56071 * pt.c (maybe_instantiate_noexcept): Don't defer access checks. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e38aca6..01d4295 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18429,12 +18429,14 @@ maybe_instantiate_noexcept (tree fn) if (push_tinst_level (fn)) { push_access_scope (fn); + push_deferring_access_checks (dk_no_deferred); input_location = DECL_SOURCE_LOCATION (fn); noex = tsubst_copy_and_build (DEFERRED_NOEXCEPT_PATTERN (noex), DEFERRED_NOEXCEPT_ARGS (noex), tf_warning_or_error, fn, /*function_p=*/false, /*integral_constant_expression_p=*/true); + pop_deferring_access_checks (); pop_access_scope (fn); pop_tinst_level (); spec = build_noexcept_spec (noex, tf_warning_or_error); diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept20.C b/gcc/testsuite/g++.dg/cpp0x/noexcept20.C new file mode 100644 index 0000000..b867602 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept20.C @@ -0,0 +1,22 @@ +// PR c++/56071 +// { dg-options -std=c++11 } + +class B +{ + template friend struct A; + B() {} +}; + +template +struct A +{ + A() noexcept(noexcept(B())) { } +}; + +struct C +{ + C() + { + static_assert( !noexcept(A()), "" ); + } +};