From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103548 invoked by alias); 31 Jan 2019 15:22:52 -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 103511 invoked by uid 89); 31 Jan 2019 15:22:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk1-f176.google.com Received: from mail-qk1-f176.google.com (HELO mail-qk1-f176.google.com) (209.85.222.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Jan 2019 15:22:50 +0000 Received: by mail-qk1-f176.google.com with SMTP id q8so2096481qke.1 for ; Thu, 31 Jan 2019 07:22:50 -0800 (PST) Return-Path: Received: from [192.168.1.115] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id q72sm5814606qki.24.2019.01.31.07.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 07:22:47 -0800 (PST) Subject: Re: [C++PATCH] [PR86379] do not use TREE_TYPE for USING_DECL_SCOPE To: Alexandre Oliva , gcc-patches@gcc.gnu.org Cc: nathan@acm.org References: From: Jason Merrill Message-ID: <54a97dd0-58e0-d799-5297-fccb6801ae5f@redhat.com> Date: Thu, 31 Jan 2019 15:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg01797.txt.bz2 On 1/30/19 8:07 PM, Alexandre Oliva wrote: > It's too risk to reuse the type field for USING_DECL_SCOPE. > Language-independent parts of the compiler, such as location and > non-lvalue wrappers, happily take the TREE_TYPE of a USING_DECL as if > it was a type rather than an unrelated scope. > > For better or worse, USING_DECLs use the non-common struct so we can > use the otherwise unused result field. Adjust fallout, from uses of > TREE_TYPE that were supposed to be USING_DECL_SCOPE, to other > accidental uses of TREE_TYPE of a USING_DECL. > > Regstrapped on x86_64- and i686-linux-gnu. Ok to install? > (but see the additional patchlet below) > > > for gcc/cp/ChangeLog > > PR c++/86379 > * cp-tree.h (USING_DECL_SCOPE): Use result rather than type. > * name-lookup.c (strip_using_decl): Use USING_DECL_SCOPE. > * search.c (protected_accessible_p): Follow USING_DECL_DECLS. > (shared_member_p): Likewise. > (lookup_member): Likewise. > * decl.c (copy_fn_p): Likewise. > (grok_special_member_properties): Do not test USING_DECL for > staticness. > * semantics.c (finish_omp_declare_simd_methods): Likewise. > > for gcc/testsuite/ChangeLog > > PR c++/86379 > * g++.dg/cpp0x/pr86379.C: New. > --- > gcc/cp/cp-tree.h | 2 > gcc/cp/decl.c | 10 +- > gcc/cp/name-lookup.c | 2 > gcc/cp/search.c | 23 +++- > gcc/cp/semantics.c | 3 > gcc/testsuite/g++.dg/cpp0x/pr86379.C | 207 ++++++++++++++++++++++++++++++++++ > 6 files changed, 240 insertions(+), 7 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr86379.C > > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > index 77e1425b4357b..053ed5ace6d42 100644 > --- a/gcc/cp/cp-tree.h > +++ b/gcc/cp/cp-tree.h > @@ -3288,7 +3288,7 @@ struct GTY(()) lang_decl { > #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE)) > > /* The scope named in a using decl. */ > -#define USING_DECL_SCOPE(NODE) TREE_TYPE (USING_DECL_CHECK (NODE)) > +#define USING_DECL_SCOPE(NODE) DECL_RESULT_FLD (USING_DECL_CHECK (NODE)) > > /* The decls named by a using decl. */ > #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE)) > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c > index 79eeac177b64c..86101d3bc3b45 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -13174,6 +13174,13 @@ copy_fn_p (const_tree d) > tree arg_type; > int result = 1; > > + while (TREE_CODE (d) == USING_DECL) > + { > + d = USING_DECL_DECLS (d); > + if (!d) > + return result; > + } Let's use strip_using_decl instead of writing the loop here and in the other similar places. > @@ -13288,7 +13295,8 @@ grok_special_member_properties (tree decl) > { > tree class_type; > > - if (!DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) > + if (TREE_CODE (decl) != USING_DECL > + && !DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) > return; Is there a reason not to use it here, as well? Jason