[gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] c++: more constrained nested partial specialization
Tamar Christina
tnfchris@gcc.gnu.org
Fri Jul 17 15:08:04 GMT 2020
https://gcc.gnu.org/g:6effd8a7264427785f999536fc37fd771df190ee
commit 6effd8a7264427785f999536fc37fd771df190ee
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jun 4 13:04:01 2020 -0400
c++: more constrained nested partial specialization
When checking that a constrained partial specialization is more
constrained than the primary template, we pass only the innermost level
of generic template arguments to strictly_subsumes. This leads to us
doing a nonsensical substitution from normalize_concept_check if the
full set of template arguments has multiple levels, and it ultimately
causes strictly_subsumes to sometimes erroneously return false as in the
testcase below.
gcc/cp/ChangeLog:
* pt.c (process_partial_specialization): Pass the full set of
generic template arguments to strictly_subsumes.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-partial-spec8.C: New test.
(cherry picked from commit c06280ac4c34b0aff8cfa2e74ae8c7afd759d52f)
Diff:
---
gcc/cp/pt.c | 2 +-
gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3e786f8032e..732900e4796 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5053,7 +5053,7 @@ process_partial_specialization (tree decl)
if (comp_template_args (inner_args, INNERMOST_TEMPLATE_ARGS (main_args))
&& (!flag_concepts
|| !strictly_subsumes (current_template_constraints (),
- inner_args, maintmpl)))
+ main_args, maintmpl)))
{
if (!flag_concepts)
error ("partial specialization %q+D does not specialize "
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C
new file mode 100644
index 00000000000..873cf44e407
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec8.C
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++20 } }
+
+template<int M, int N>
+concept equal = M == N;
+
+template<int M>
+struct traits
+{
+ template<int N> requires equal<M, N>
+ struct foo {};
+
+ template<int N> requires equal<M, N> && (M >= 0) // { dg-bogus "not more constrained" }
+ struct foo<N> {};
+};
More information about the Gcc-cvs
mailing list