Re: [PATCH] c++: ttp variadic constraint subsumption [PR99904]
On 10/1/21 16:10, Patrick Palka wrote: Here we're crashing when level-lowering the variadic constraints on the template template parameter TT because tsubst_pack_expansion expects processing_template_decl to be set during a partial substitution. bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? Also tested on cmcstl2 and range-v3. OK. PR c++/99904 gcc/cp/ChangeLog: * pt.c (is_compatible_template_arg): Set processing_template_decl around tsubst_constraint_info. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-ttp4.C: New test. --- gcc/cp/pt.c| 2 ++ gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C | 9 + 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1dcdffe322a..f950f4a21b7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8223,8 +8223,10 @@ is_compatible_template_arg (tree parm, tree arg) { tree aparms = DECL_INNERMOST_TEMPLATE_PARMS (arg); new_args = template_parms_level_to_args (aparms); + ++processing_template_decl; parm_cons = tsubst_constraint_info (parm_cons, new_args, tf_none, NULL_TREE); + --processing_template_decl; if (parm_cons == error_mark_node) return false; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C new file mode 100644 index 000..cf3e71ea974 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C @@ -0,0 +1,9 @@ +// PR c++/99904 +// { dg-do compile { target c++20 } } + +template concept C = (Ts::value && ...); +template requires C struct A; +template requires true struct B; +template requires C class TT> struct S; +using ty1 = S; +using ty2 = S; // { dg-error "constraint" } TT's constraints don't subsume B's
[PATCH] c++: ttp variadic constraint subsumption [PR99904]
Here we're crashing when level-lowering the variadic constraints on the template template parameter TT because tsubst_pack_expansion expects processing_template_decl to be set during a partial substitution. bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? Also tested on cmcstl2 and range-v3. PR c++/99904 gcc/cp/ChangeLog: * pt.c (is_compatible_template_arg): Set processing_template_decl around tsubst_constraint_info. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-ttp4.C: New test. --- gcc/cp/pt.c| 2 ++ gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C | 9 + 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1dcdffe322a..f950f4a21b7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8223,8 +8223,10 @@ is_compatible_template_arg (tree parm, tree arg) { tree aparms = DECL_INNERMOST_TEMPLATE_PARMS (arg); new_args = template_parms_level_to_args (aparms); + ++processing_template_decl; parm_cons = tsubst_constraint_info (parm_cons, new_args, tf_none, NULL_TREE); + --processing_template_decl; if (parm_cons == error_mark_node) return false; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C new file mode 100644 index 000..cf3e71ea974 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C @@ -0,0 +1,9 @@ +// PR c++/99904 +// { dg-do compile { target c++20 } } + +template concept C = (Ts::value && ...); +template requires C struct A; +template requires true struct B; +template requires C class TT> struct S; +using ty1 = S; +using ty2 = S; // { dg-error "constraint" } TT's constraints don't subsume B's -- 2.33.0.610.gcefe983a32