c++: Fix CTAD for aggregates in template [PR95568]
95568 complains that CTAD for aggregates doesn't work within
requires-clause and it turned out that it doesn't work when we try
the deduction in a template. The reason is that maybe_aggr_guide
creates a guide that can look like this
template<class T> X(decltype (X<T>::x))-> X<T>
where the parameter is a decltype, which is a non-deduced context. So
the subsequent build_new_function_call fails because unify_one_argument
can't deduce anything from it ([temp.deduct.type]: "If a template
parameter is used only in non-deduced contexts and is not explicitly
specified, template argument deduction fails.")
Those decltypes come from finish_decltype_type. We can just use
TREE_TYPE instead. I pondered using unlowered_expr_type, but that
didn't make any difference for the FIELD_DECLs I saw in
class-deduction-aggr6.C.
gcc/cp/ChangeLog:
PR c++/95568
* pt.c (collect_ctor_idx_types): Use TREE_TYPE.
gcc/testsuite/ChangeLog:
PR c++/95568
* g++.dg/cpp2a/class-deduction-aggr5.C: New test.
* g++.dg/cpp2a/class-deduction-aggr6.C: New test.