From patchwork Sun Mar 17 01:52:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 228265 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 F3F6B2C008A for ; Sun, 17 Mar 2013 12:52:29 +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=1364089950; 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=2vfVjVX R9tQJdW3KoXO0+VL/uEs=; b=A2z/RtHXQ7CQzenLx6w2AJin2MDh7K+JdmsMWxn JpoFZjglHzTW4qrIrqsD32qTRn5tyuGCK7b01bBxlGiFbweB00nMrttf2AWfrU7G b3Iudn3H7un0817EtoUjoGw6rkXEGMle2VYm+g/9+56AS9HhTajm+qHNBY0jcofP fZ/o= 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=Tpo3hSHhRumVplQldKADreHyXHYY84rLVnPa7O4tQAkMtOviVmmcRQygPRRSHC NxMNrZsgTuiWJDWoy0h8eRR+k3wUHwHHCTWqtFyZVclAvem3Ox1iMFZt6LAMx+Zt NcqTGg85Kmx1KGXhNWOFG1/MfxmgAvIk9TpE3ohASd9LU=; Received: (qmail 12053 invoked by alias); 17 Mar 2013 01:52:24 -0000 Received: (qmail 11926 invoked by uid 22791); 17 Mar 2013 01:52:23 -0000 X-SWARE-Spam-Status: No, hits=-7.6 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; Sun, 17 Mar 2013 01:52:11 +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 r2H1qBsV030453 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 16 Mar 2013 21:52:11 -0400 Received: from [10.3.113.56] (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2H1qA94016645 for ; Sat, 16 Mar 2013 21:52:11 -0400 Message-ID: <514521CA.3000207@redhat.com> Date: Sat, 16 Mar 2013 21:52:10 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/45917 (missing access error with template-id nested-name-specifier) 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 We were saving up the access check perfectly well, but then inadvertently throwing it away because of a call to pop_deferring_access_checks (which discards them) rather than pop_to_parent_deferring_access_checks (which adds them to the parent context). Tested x86_64-pc-linux-gnu, applying to trunk. commit 93fa63b45d657409ab35823b824f3acaa3e8b1ae Author: Jason Merrill Date: Thu Mar 14 17:14:07 2013 -0400 PR c++/45917 * parser.c (cp_parser_template_id): Don't forget access checks. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b0df636..f4a4278 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12818,7 +12818,7 @@ cp_parser_template_id (cp_parser *parser, error_at (token->location, "parse error in template argument list"); } - pop_deferring_access_checks (); + pop_to_parent_deferring_access_checks (); return template_id; } diff --git a/gcc/testsuite/g++.dg/template/access26.C b/gcc/testsuite/g++.dg/template/access26.C new file mode 100644 index 0000000..1c5de9a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access26.C @@ -0,0 +1,6 @@ +// PR c++/45917 + +template < typename T > +struct A { static int i; }; +class B { typedef int X; }; // { dg-error "private" } +void f() { A::i = 0; } // { dg-error "this context" }