On 10/29/20 11:21 AM, Patrick Palka wrote:
On Mon, 19 Oct 2020, Patrick Palka wrote:
When normalizing the constraint-expression of a nested-requirement, we
pass NULL_TREE as the initial template arguments for normalization, but
tsubst_argument_pack is not prepared to handle a NULL_TREE targ vector.
This causes us to ICE when normalizing a variadic concept as part of a
nested-requirement.
This patch fixes the ICE by guarding the call to tsubst_template_args in
normalize_concept_check appropriately. This will also enables us to
simplify many of the normalization routines to pass NULL_TREE instead of
a set of generic template arguments as the initial template arguments,
which will be done in a subsequent patch.
Ping. For some reason I confusingly referred to 'targs' in the commit
message when the variable in question is actually 'args'. So I've
adjusted the commit message below:
OK.
-- >8 --
Subject: [PATCH] c++: Tolerate empty initial args during normalization
[PR97412]
When normalizing the constraint-expression of a nested-requirement, we
pass NULL_TREE as the initial template arguments for normalization, but
tsubst_argument_pack is not prepared to handle a NULL_TREE args vector.
This causes us to ICE when normalizing a variadic concept as part of a
nested-requirement.
This patch fixes the ICE by guarding the call to tsubst_template_args in
normalize_concept_check appropriately. This will also enable us to
simplify many of the normalization routines to just pass NULL_TREE
(instead of a set of generic template arguments) as the initial template
arguments.
gcc/cp/ChangeLog:
PR c++/97412
* constraint.cc (normalize_concept_check): Don't call
tsubst_template_args when 'args' is NULL.
gcc/testsuite/ChangeLog:
PR c++/97412
* g++.dg/cpp2a/concepts-variadic2.C: New test.
---
gcc/cp/constraint.cc | 3 ++-
gcc/testsuite/g++.dg/cpp2a/concepts-variadic2.C | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-variadic2.C
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index f4f5174eff3..75457a2dd60 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -686,7 +686,8 @@ normalize_concept_check (tree check, tree args, norm_info
info)
}
/* Substitute through the arguments of the concept check. */
- targs = tsubst_template_args (targs, args, info.complain, info.in_decl);
+ if (args)
+ targs = tsubst_template_args (targs, args, info.complain, info.in_decl);
if (targs == error_mark_node)
return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-variadic2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic2.C
new file mode 100644
index 00000000000..ce61aef5481
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-variadic2.C
@@ -0,0 +1,12 @@
+// PR c++/97412
+// { dg-do compile { target c++20 } }
+
+template <class T, class... TArgs>
+concept call_bar_with = requires(T t, TArgs... args) {
+ t.bar(args...);
+};
+
+template <class T, class... TArgs>
+concept foo = requires {
+ requires call_bar_with<T, TArgs...>;
+};