diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-09-28 17:26:20 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-09-28 17:26:20 -0400 |
commit | daa762f01d8cf932484b7df122a5e872439bc92c (patch) | |
tree | 063ac2526b95709c1d3f05da5c45acba98d6f260 /gcc | |
parent | 2fcfc7d66862c67677f0e1c46391292d5a21a567 (diff) | |
download | gcc-daa762f01d8cf932484b7df122a5e872439bc92c.zip gcc-daa762f01d8cf932484b7df122a5e872439bc92c.tar.gz gcc-daa762f01d8cf932484b7df122a5e872439bc92c.tar.bz2 |
c++: ttp matching with constrained auto parm [PR99909]
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 by making sure processing_template_decl is set
around 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.
PR c++/99909
gcc/cp/ChangeLog:
* pt.c (coerce_template_template_parms): Keep
processing_template_decl set around the call to unify as well.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-ttp3.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-ttp3.C | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 41fa7ed..1dcdffe 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 0000000..11b6293 --- /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>(); |