From: Patrick Palka Date: Sun, 7 May 2023 16:05:24 +0000 (-0400) Subject: c++: satisfaction of non-dep member alias template-id X-Git-Tag: basepoints/gcc-15~9577 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b28a7c41fb4697b2d5d9e6e6552b0764bd7d90f0;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index bb4e275d714b..d400b9f3eb25 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 000000000000..55f25a7ccf80 --- /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 +struct A { + template requires (N > 0) + using at = T; + + void f() { + using ty1 = at<0>; // { dg-error "constraint" } + using ty2 = at<1>; + } +};