c++: Some preparatory type canonicalization fixes
The patches that follow revealed some latent type canonicalization
issues during normalization/satisfaction, due to normalization of
some constraint-expressions now being performed in different contexts
and more frequently (since the normalization caches get frequently
emptied in a checking compiler). The issues are:
1. In tsubst_parameter_mapping, we canonicalize the arguments of a
substituted TYPE_ARGUMENT_PACK only if the argument we started with
wasn't a TYPE_ARGUMENT_PACK. We should canonicalize a substituted
TYPE_ARGUMENT_PACK regardless of what we started with.
2. We currently set DECL_CONTEXT and CONSTRAINT_VAR_P on each of the
parameters introduced in a requires expression _after_ we're done
processing the requirements. But meanwhile we may have already
built and computed the canonical form of a type that uses one of
these PARM_DECLs (as say an operand to decltype). But the canonical
form depends on the result of cp_tree_equal, which in turn depends on
the value of CONSTRAINT_VAR_P and DECL_CONTEXT. So we must set these
fields earlier, before processing requirements.
3. In do_auto_deduction, we use the result of finish_decltype_type later
as a template argument, so we should canonicalize the result too.
(While we're here, we should pass 'complain' to finish_decltype_type,
which fixes the testcase auto1.C below.)
gcc/cp/ChangeLog:
* constraint.cc (tsubst_parameter_mapping): Canonicalize the
arguments of a substituted TYPE_ARGUMENT_PACK even if we've
started with a TYPE_ARGUMENT_PACK.
(finish_requires_expr): Don't set DECL_CONTEXT and
CONSTRAINT_VAR_P on each of the introduced parameters here.
* parser.c (cp_parser_requirement_parameter_list): Instead set
these fields earlier, here.
* pt.c (do_auto_deduction): Canonicalize the result of
do_auto_deduction. Pass 'complain' to finish_decltype_type.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/auto1.C: New test.