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>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: ttp matching with constrained auto parm [PR99909]
Date: Tue, 28 Sep 2021 15:42:20 -0400	[thread overview]
Message-ID: <53c7e21a-8c03-2411-e36a-bd8df1bd60c4@redhat.com> (raw)
In-Reply-To: <20210928191541.3143405-1-ppalka@redhat.com>

On 9/28/21 15:15, Patrick Palka wrote:
> Here, when unifying TT with S, processing_template_decl is unset, and
> this foils the dependence checks in do_auto_deduction for avoiding
> checking constraints on an auto when the initializer is dependent.
> 
> This patch fixes this issue by making sure processing_template_decl is
> set during the call to unify from coerce_template_template_parms; this
> seems sensible because we're unifying one set of template parameters
> with another, so we're dealing with templated trees throughout.

> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?

OK.

> 	PR c++/99909
> 
> gcc/cp/ChangeLog:
> 
> 	* pt.c (coerce_template_template_parms): Keep
> 	processing_template_decl set during the call to unify as well.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp2a/concepts-ttp3.C: New test.
> ---
>   gcc/cp/pt.c                                |  4 ++--
>   gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C | 11 +++++++++++
>   2 files changed, 13 insertions(+), 2 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C
> 
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index 41fa7ed5e43..1dcdffe322a 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -7994,12 +7994,12 @@ coerce_template_template_parms (tree parm_parms,
>         /* So coerce P's args to apply to A's parms, and then deduce between A's
>   	 args and the converted args.  If that succeeds, A is at least as
>   	 specialized as P, so they match.*/
> +      processing_template_decl_sentinel ptds (/*reset*/false);
> +      ++processing_template_decl;
>         tree pargs = template_parms_level_to_args (parm_parms);
>         pargs = add_outermost_template_args (outer_args, pargs);
> -      ++processing_template_decl;
>         pargs = coerce_template_parms (arg_parms, pargs, NULL_TREE, tf_none,
>   				     /*require_all*/true, /*use_default*/true);
> -      --processing_template_decl;
>         if (pargs != error_mark_node)
>   	{
>   	  tree targs = make_tree_vec (nargs);
> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C
> new file mode 100644
> index 00000000000..898524e0dfa
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C
> @@ -0,0 +1,11 @@
> +// PR c++/99909
> +// { dg-do compile { target c++20 } }
> +
> +template<class T> constexpr bool always_true = true;
> +template<class T> concept C = always_true<T>;
> +
> +template<C auto> struct S { };
> +
> +template<template<auto> class TT> void f() { }
> +
> +template void f<S>();
> 


      reply	other threads:[~2021-09-28 19:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 19:15 Patrick Palka
2021-09-28 19:42 ` Jason Merrill [this message]

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=53c7e21a-8c03-2411-e36a-bd8df1bd60c4@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).