diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index afd5435cc3e..7fce78f508e 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3328,13 +3328,14 @@ strictly_subsumes (tree ci, tree tmpl) return subsumes (n1, n2) && !subsumes (n2, n1); } -/* Returns true when the constraints in CI subsume the - associated constraints of TMPL. */ +/* Returns true when the template template parameter constraints in CI + subsume the associated constraints of the template template argument + TMPL. */ bool -weakly_subsumes (tree ci, tree tmpl) +ttp_subsumes (tree ci, tree tmpl) { - tree n1 = get_normalized_constraints_from_info (ci, NULL_TREE); + tree n1 = get_normalized_constraints_from_info (ci, tmpl); tree n2 = get_normalized_constraints_from_decl (tmpl); return subsumes (n1, n2); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 76ac9c31763..856699de82f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8609,7 +8609,7 @@ extern tree find_template_parameters (tree, tree); extern bool equivalent_constraints (tree, tree); extern bool equivalently_constrained (tree, tree); extern bool strictly_subsumes (tree, tree); -extern bool weakly_subsumes (tree, tree); +extern bool ttp_subsumes (tree, tree); extern int more_constrained (tree, tree); extern bool at_least_as_constrained (tree, tree); extern bool constraints_equivalent_p (tree, tree); diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8cc5e21c520..393913294b5 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -8482,7 +8482,7 @@ is_compatible_template_arg (tree parm, tree arg, tree args) return false; } - return weakly_subsumes (parm_cons, arg); + return ttp_subsumes (parm_cons, arg); } // Convert a placeholder argument into a binding to the original diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C new file mode 100644 index 00000000000..2ce884b995c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C @@ -0,0 +1,12 @@ +// PR c++/115656 +// { dg-do compile { target c++20 } } + +template concept same_as = __is_same(T, U); + +template T, template> class UU> +struct A { }; + +template> class B; + +A a1; +A a2; // { dg-error "constraint failure" }