c++: return-type-req in constraint using only outer tparms [PR104527]
authorPatrick Palka <ppalka@redhat.com>
Sat, 12 Mar 2022 20:00:40 +0000 (15:00 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sat, 12 Mar 2022 20:00:40 +0000 (15:00 -0500)
commit9413bb55185b9e88d84e91d5145d59f9f83b884a
treea5495acc5806a95ad66ddfaf09d6d8b023fbc163
parentab71d3fe4b23af4c29a8d6fcf1e914fed4393e3b
c++: return-type-req in constraint using only outer tparms [PR104527]

Here the template context for the atomic constraint has two levels of
template parameters, but since it depends only on the innermost parameter
T we use a single-level argument vector (built by get_mapped_args) during
substitution into the atom.  We eventually pass this vector to
do_auto_deduction as part of checking the return-type-requirement within
the atom, but do_auto_deduction expects outer_targs to be a full set of
arguments for sake of satisfaction.

This patch fixes this by making get_mapped_args always return an
argument vector whose depth corresponds to the template depth of the
context in which the atomic constraint expression was written, instead
of the highest parameter level that the expression happens to use.

PR c++/104527

gcc/cp/ChangeLog:

* constraint.cc (normalize_atom): Set
ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P appropriately.
(get_mapped_args):  Make static, adjust parameters.  Always
return a vector whose depth corresponds to the template depth of
the context of the atomic constraint expression.  Micro-optimize
by passing false as exact to safe_grow_cleared and by collapsing
a multi-level depth-one argument vector.
(satisfy_atom): Adjust call to get_mapped_args and
diagnose_atomic_constraint.
(diagnose_atomic_constraint): Replace map parameter with an args
parameter.
* cp-tree.h (ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P): Define.
(get_mapped_args): Remove declaration.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-return-req4.C: New test.
gcc/cp/constraint.cc
gcc/cp/cp-tree.h
gcc/testsuite/g++.dg/cpp2a/concepts-return-req4.C [new file with mode: 0644]