public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: naming a dependently-scoped template for CTAD [PR104641]
Date: Wed, 9 Mar 2022 23:52:17 -0500	[thread overview]
Message-ID: <508f82dd-76d5-d42e-67ba-a4f675a9ad90@redhat.com> (raw)
In-Reply-To: <f502b34a-007c-ff20-1705-593b96196c47@idea>

On 3/9/22 10:39, Patrick Palka wrote:
> On Tue, 8 Mar 2022, Jason Merrill wrote:
> 
>> On 3/2/22 14:32, Patrick Palka wrote:
>>> In order to be able to perform CTAD for a dependently-scoped template
>>> such as A<T>::B in the testcase below, we need to permit a
>>> typename-specifier to resolve to a template as per [dcl.type.simple]/2,
>>> at least when it appears in a CTAD-enabled context.
>>>
>>> This patch implements this using a new tsubst flag tf_tst_ok to control
>>> when a TYPENAME_TYPE is allowed to name a template, and sets this flag
>>> when substituting into the type of a CAST_EXPR, CONSTRUCTOR or VAR_DECL
>>> (each of which is a CTAD-enabled context).
>>
>> What breaks if we always allow that, or at least in -std that support CTAD?
> 
> AFAICT no significant breakage, but some accepts-invalid and diagnostic
> regressions crop up, e.g. accepts-invalid for
> 
>    using type = typename A<T>::B; // no more diagnostic if typename resolves to a
>                                   // template at instantiation time
> 
> and diagnostic regression for
> 
>    template<class T, class = typename A<T>::B> void f();
>    // no more elaboration why deduction failed if typename resolves
>    // to a template

Ah, sure, the cost is that we would need to check for this case in 
various callers, rather than setting a flag in a different set of 
callers.  Fair enough.

> @@ -16229,6 +16237,12 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>  	      }
>  	  }
>  
> +	if (TREE_CODE (f) == TEMPLATE_DECL)
> +	  {
> +	    gcc_checking_assert (tst_ok);
> +	    f = make_template_placeholder (f);
> +	  }

How about calling make_template_placeholder in make_typename_type?

Jason


  reply	other threads:[~2022-03-10  4:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 18:32 Patrick Palka
2022-03-08 23:10 ` Jason Merrill
2022-03-09 14:39   ` Patrick Palka
2022-03-10  4:52     ` Jason Merrill [this message]
2022-03-10 16:41       ` Patrick Palka
2022-03-11 23:49         ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=508f82dd-76d5-d42e-67ba-a4f675a9ad90@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).