diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/cp/constraint.cc | 9 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-return-req3.C | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 03ce8eb..74b16d2 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3065,6 +3065,15 @@ normalize_placeholder_type_constraints (tree t, bool diag) scope for this placeholder type; use them as the initial template parameters for normalization. */ tree initial_parms = TREE_PURPOSE (ci); + + if (!initial_parms && TEMPLATE_TYPE_LEVEL (t) == 2) + /* This is a return-type-requirement of a non-templated requires-expression, + which are parsed under processing_template_decl == 1 and empty + current_template_parms; hence the 'auto' has level 2 and initial_parms + is empty. Fix up initial_parms to be consistent with the value of + processing_template_decl whence the 'auto' was created. */ + initial_parms = build_tree_list (size_int (1), make_tree_vec (0)); + /* The 'auto' itself is used as the first argument in its own constraints, and its level is one greater than its template depth. So in order to capture all used template parameters, we need to add an extra level of diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-return-req3.C b/gcc/testsuite/g++.dg/cpp2a/concepts-return-req3.C new file mode 100644 index 0000000..a546c64 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-return-req3.C @@ -0,0 +1,6 @@ +// PR c++/100946 +// { dg-do compile { target c++20 } } + +template<class T> concept C = __is_same(T, int); +static_assert(requires { { 0 } -> C; }); +static_assert(requires { { true } -> C; }); // { dg-error "failed" } |
