From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20535 invoked by alias); 6 Dec 2018 01:25:19 -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 20510 invoked by uid 89); 6 Dec 2018 01:25:18 -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-qt1-f173.google.com Received: from mail-qt1-f173.google.com (HELO mail-qt1-f173.google.com) (209.85.160.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Dec 2018 01:25:16 +0000 Received: by mail-qt1-f173.google.com with SMTP id t13so24650340qtn.3 for ; Wed, 05 Dec 2018 17:25:16 -0800 (PST) Return-Path: Received: from [192.168.1.132] (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 q84sm15455590qkh.56.2018.12.05.17.25.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 17:25:14 -0800 (PST) Subject: Re: [PATCH] [PR87012] canonicalize ref type for tmpl arg To: Alexandre Oliva , gcc-patches@gcc.gnu.org Cc: nathan@acm.org References: From: Jason Merrill Message-ID: <2bcaf9b3-e544-4146-fe5f-cd39a5f23e6f@redhat.com> Date: Thu, 06 Dec 2018 01:25: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: 2018-12/txt/msg00333.txt.bz2 On 11/16/18 5:32 PM, Alexandre Oliva wrote: > When binding an object to a template parameter of reference type, we > take the address of the object and dereference that address. The type > of the address may still carry (template) typedefs, but > verify_unstripped_args_1 rejects such typedefs other than in the top > level of template arguments. > > We might special-case INDIRECT_REFs, but I suppose we're better off > canonicalizing the desired type for the address before converting to > it. > > Regstrapped on i686- and x86_64-linux-gnu. Ok to install? > > > for gcc/cp/ChangeLog > > PR c++/87012 > * pt.c (canonicalize_type_argument): Declare earlier. > (convert_nontype_argument): Call it on addr expr. > > for gcc/testsuite/ChangeLog > > PR c++/87012 > * g++.dg/cpp0x/pr87012.C: New. > --- > gcc/cp/pt.c | 4 ++++ > gcc/testsuite/g++.dg/cpp0x/pr87012.C | 11 +++++++++++ > 2 files changed, 15 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr87012.C > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > index b58ec06a09e5..83d0a74b209f 100644 > --- a/gcc/cp/pt.c > +++ b/gcc/cp/pt.c > @@ -227,6 +227,8 @@ static tree make_argument_pack (tree); > static void register_parameter_specializations (tree, tree); > static tree enclosing_instantiation_of (tree tctx); > > +static tree canonicalize_type_argument (tree arg, tsubst_flags_t complain); > + > /* Make the current scope suitable for access checking when we are > processing T. T can be FUNCTION_DECL for instantiated function > template, VAR_DECL for static member variable, or TYPE_DECL for > @@ -7016,6 +7018,8 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) > return NULL_TREE; > } > > + type = canonicalize_type_argument (type, complain); I would expect that this same issue would come up with other types; I think we want to fix this sooner, when we are figuring out what type we want to convert the argument to. Jason