From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 60DBC39551C5 for ; Wed, 2 Jun 2021 20:56:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 60DBC39551C5 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-_IKRJFcgNEahb09Todd0HA-1; Wed, 02 Jun 2021 16:56:26 -0400 X-MC-Unique: _IKRJFcgNEahb09Todd0HA-1 Received: by mail-qt1-f198.google.com with SMTP id u3-20020a05622a0103b02902274c59d552so2132311qtw.23 for ; Wed, 02 Jun 2021 13:56:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=er7fWRrVJYeC/xrNnEQ5VhXj44cTVDQk59LdV/tHnUA=; b=b9KzbHOkEYydQmKuwasRbOavvJwnCKzoCTTop/TlcHQaHNjoT53CzqaSE4M8Bc90CU 34b7DUxlNo85pJiYorzGdHiRRe0myxckcFOVpXME9a1ywL8WHFbyg2bQn3lzydS2B58y X7xsxMrSHNEarsc/+0wUMYTTzUg/vQrr03LNjGMpNM32JaB9fONZpxVQFLGuxtNhQKbU XkdBS/yv1TDLxmZ1mVujY1O5p58gC3qMqvaYcxbpWbx7puqia6HD6QrMcoaeXo5DomhQ dO459kwXVztT4lWtTzAejEcvAed/uVonADbzwxj55YTnO5kyPHqoNWF2tVCAE4J4W+Xf 8JxA== X-Gm-Message-State: AOAM530svHWXuoA27EepxsJfQ3R1/J3/o17C7khaIx9nqROcDv0UZ5ms hFpaA4WTSpCrSou77mLVadQW7x2dV2TTowCJHwac66mKuPNmYJ4hk9e/EKUHBe9lrB+6jKZ+J+U xlnO0dnteMPAIXni+dw== X-Received: by 2002:ae9:f010:: with SMTP id l16mr10139606qkg.424.1622667385949; Wed, 02 Jun 2021 13:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySrGTA/7eE0i/q3Mh0oWBzFYRgHqqFQcbZVSTxL4pMDRQD8tiTjDitNdv3K99+J84+HcqBng== X-Received: by 2002:ae9:f010:: with SMTP id l16mr10139591qkg.424.1622667385684; Wed, 02 Jun 2021 13:56:25 -0700 (PDT) Received: from [192.168.1.130] (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id l197sm598054qke.121.2021.06.02.13.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 13:56:25 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Wed, 2 Jun 2021 16:56:24 -0400 (EDT) To: Patrick Palka cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: cv-qualified dependent name of alias tmpl [PR100592] In-Reply-To: <9a51cdb0-82cf-e690-e4cf-2c8df49adce1@idea> Message-ID: References: <20210602183934.958366-1-ppalka@redhat.com> <0e38e572-6392-a172-8873-7985eacac30c@redhat.com> <9a51cdb0-82cf-e690-e4cf-2c8df49adce1@idea> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-16.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 20:56:29 -0000 On Wed, 2 Jun 2021, Patrick Palka wrote: > On Wed, 2 Jun 2021, Jason Merrill wrote: > > > On 6/2/21 2:39 PM, Patrick Palka wrote: > > > Here, the dependent template name in the return type of f() resolves to > > > an alias of int& after substitution, and we end up complaining about > > > qualifying this reference type with 'const' from cp_build_qualified_type > > > rather than just silently dropping the qualification as per [dcl.ref]/1. > > > > Hmm, the patch looks fine, but why does the TYPE_DECL test fail for the alias? > > Ah, I hadn't considered investigating that. It seems make_typename_type > always returns a _TYPE instead of a TYPE_DECL when resolving a dependent > name that's a template-id, regardless of the tf_keep_type_decl flag. > This can be easily fixed like so, and this change alone is sufficient to > fix the PR (no changes to qualttp20.C needed). Note that this change > should only have an effect when tf_keep_type_decl is passed to > make_typename_type, and the only such caller is the TYPENAME_TYPE case > of tsubst in question, so this change seems pretty safe. > > The downside is that we don't get the __restrict__-dropping > "improvement" as exhibited by qualttp20.C that the original patch > provides, so this other approach is more conservative in that sense. > > So shall we go with the original patch, or something like the following? > (If we go with the original patch, it just occurred to me that we could > remove tf_keep_type_decl altogether.) Testing in progress. For sake of concreteness, here's the full alternative patch for consideration (modulo ChangeLog): -- >8 -- --- gcc/cp/decl.c | 13 +++++++++---- gcc/testsuite/g++.dg/cpp0x/alias-decl-71.C | 13 +++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-71.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fb21a3a1ae8..1be232af483 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4136,10 +4136,15 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, return error_mark_node; if (want_template) - return lookup_template_class (t, TREE_OPERAND (fullname, 1), - NULL_TREE, context, - /*entering_scope=*/0, - complain | tf_user); + { + t = lookup_template_class (t, TREE_OPERAND (fullname, 1), + NULL_TREE, context, + /*entering_scope=*/0, + complain | tf_user); + if (!TYPE_P (t)) + return t; + t = TYPE_NAME (t); + } if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl)) t = TREE_TYPE (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-71.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-71.C new file mode 100644 index 00000000000..6a61f93a0b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-71.C @@ -0,0 +1,13 @@ +// PR c++/100592 +// { dg-do compile { target c++11 } } + +template +struct meta { + template using if_c = int&; +}; + +template +typename meta::template if_c const f(); + +using type = decltype(f()); +using type = int&; -- 2.32.0.rc2