aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-05-07 12:05:24 -0400
committerPatrick Palka <ppalka@redhat.com>2023-05-07 12:05:24 -0400
commitb28a7c41fb4697b2d5d9e6e6552b0764bd7d90f0 (patch)
tree381878329d26c894a616b768a0fd2d46f2ad54e1 /gcc
parent5dfe5d7d17dc9eefd8e4dd0684e6d8405d2e2759 (diff)
downloadgcc-b28a7c41fb4697b2d5d9e6e6552b0764bd7d90f0.zip
gcc-b28a7c41fb4697b2d5d9e6e6552b0764bd7d90f0.tar.gz
gcc-b28a7c41fb4697b2d5d9e6e6552b0764bd7d90f0.tar.bz2
c++: satisfaction of non-dep member alias template-id
constraints_satisfied_p already carefully checks dependence of template arguments before proceeding with satisfaction, so the dependence check in instantiate_alias_template is unnecessary and overly conservative. Getting rid of it allows us to check satisfaction ahead of time in more cases as in the below testcase. gcc/cp/ChangeLog: * pt.cc (instantiate_alias_template): Exit early upon error from coerce_template_parms. Remove dependence test guarding constraints_satisfied_p. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-alias6.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.cc6
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C15
2 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index bb4e275..d400b9f 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22181,11 +22181,11 @@ instantiate_alias_template (tree tmpl, tree args, tsubst_flags_t complain)
args = coerce_template_parms (DECL_TEMPLATE_PARMS (tmpl),
args, tmpl, complain);
+ if (args == error_mark_node)
+ return error_mark_node;
/* FIXME check for satisfaction in check_instantiated_args. */
- if (flag_concepts
- && !any_dependent_template_arguments_p (args)
- && !constraints_satisfied_p (tmpl, args))
+ if (!constraints_satisfied_p (tmpl, args))
{
if (complain & tf_error)
{
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C
new file mode 100644
index 0000000..55f25a7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C
@@ -0,0 +1,15 @@
+// Verify we can check satisfaction of a non-dependent member alias
+// template-id whose constraints don't depend on outer template
+// parameters ahead of time.
+// { dg-do compile { target c++20 } }
+
+template<class T>
+struct A {
+ template<int N> requires (N > 0)
+ using at = T;
+
+ void f() {
+ using ty1 = at<0>; // { dg-error "constraint" }
+ using ty2 = at<1>;
+ }
+};