From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69237 invoked by alias); 14 Dec 2018 14:32:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 69225 invoked by uid 89); 14 Dec 2018 14:32:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.210.67, H*RU:209.85.210.67, H*r:ip*209.85.210.67 X-HELO: mail-ot1-f67.google.com Received: from mail-ot1-f67.google.com (HELO mail-ot1-f67.google.com) (209.85.210.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Dec 2018 14:31:58 +0000 Received: by mail-ot1-f67.google.com with SMTP id s5so5542529oth.7 for ; Fri, 14 Dec 2018 06:31:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jason Merrill Date: Fri, 14 Dec 2018 14:32:00 -0000 Message-ID: Subject: Re: [PATCH] [PR86823] retain deferred access checks from outside firewall To: Alexandre Oliva Cc: gcc-patches List , Nathan Sidwell Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01061.txt.bz2 OK. On Thu, Dec 13, 2018 at 8:35 PM Alexandre Oliva wrote: > > On Dec 6, 2018, Alexandre Oliva wrote: > > > I'm giving your proposed patch a full round of testing along with other > > patches. > > [PR86823] retain deferred access checks from outside firewall > > We used to preserve deferred access check along with resolved template > ids, but a tentative parsing firewall introduced additional layers of > deferred access checks, so that we don't preserve the checks we > want to any more. > > This patch moves the deferred access checks from outside the firewall > into it. > > Regstrapped on x86_64- and i686-linux-gnu. Ok to install? > > > From: Jason Merrill > for gcc/cp/ChangeLog > > PR c++/86823 > * parser.c (cp_parser_template_id): Rearrange deferred access > checks into the firewall. > > From: Alexandre Oliva > for gcc/testsuite/ChangeLog > > PR c++/86823 > * g++.dg/pr86823.C: New. > --- > gcc/cp/parser.c | 10 ++++++---- > gcc/testsuite/g++.dg/pr86823.C | 15 +++++++++++++++ > 2 files changed, 21 insertions(+), 4 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/pr86823.C > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index adfe09e494dc..0bf0e309a588 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -16182,16 +16182,18 @@ cp_parser_template_id (cp_parser *parser, > is_declaration, > tag_type, > &is_identifier); > + > + /* Push any access checks inside the firewall we're about to create. = */ > + vec *checks =3D get_deferred_access_chec= ks (); > + pop_deferring_access_checks (); > if (templ =3D=3D error_mark_node || is_identifier) > - { > - pop_deferring_access_checks (); > - return templ; > - } > + return templ; > > /* Since we're going to preserve any side-effects from this parse, set= up a > firewall to protect our callers from cp_parser_commit_to_tentative_= parse > in the template arguments. */ > tentative_firewall firewall (parser); > + reopen_deferring_access_checks (checks); > > /* If we find the sequence `[:' after a template-name, it's probably > a digraph-typo for `< ::'. Substitute the tokens and check if we can > diff --git a/gcc/testsuite/g++.dg/pr86823.C b/gcc/testsuite/g++.dg/pr8682= 3.C > new file mode 100644 > index 000000000000..18914b00aa8d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/pr86823.C > @@ -0,0 +1,15 @@ > +// { dg-do compile } > + > +struct X { > +private: > + template > + struct Y { > + int data; > + }; > +public: > + int value; > +}; > + > +int main() { > + typename X::Y a; // { dg-error "private" } > +} > > > -- > Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo > Be the change, be Free! FSF Latin America board member > GNU Toolchain Engineer Free Software Evangelist > Hay que enGNUrecerse, pero sin perder la terGNUra jam=C3=A1s-GNUChe