@@ -65,7 +65,8 @@ static a_boolean adjust_deduction_pair(
6565 a_template_arg_ptr template_arg_list,
6666 a_type_ptr *qc_param_type,
6767 a_type_ptr *qc_arg_type,
68- a_boolean *consider_nondeduced);
68+ a_boolean *consider_nondeduced,
69+ a_boolean allow_incomplete_arg);
6970static a_boolean check_narrowing_conversion(an_operand *source_operand,
7071 a_type_ptr dest_type,
7172 a_boolean check_enum_target,
@@ -1485,7 +1486,8 @@ from previous arguments; in the standard case, it is always NULL.
14851486 (an_operand *)NULL, templ_params,
14861487 (a_template_arg *)NULL,
14871488 (a_type_ptr*)NULL, (a_type_ptr*)NULL,
1488- (a_boolean *)NULL) &&
1489+ (a_boolean *)NULL,
1490+ /*allow_incomplete_arg=*/FALSE) &&
14891491 tentatively_matches_template_type(local_arg_type,
14901492 local_param_type,
14911493 templ_params,
@@ -4272,7 +4274,8 @@ static a_boolean adjust_deduction_pair(
42724274 a_template_arg_ptr template_arg_list,
42734275 a_type_ptr *qc_param_type,
42744276 a_type_ptr *qc_arg_type,
4275- a_boolean *consider_nondeduced)
4277+ a_boolean *consider_nondeduced,
4278+ a_boolean allow_incomplete_arg)
42764279/*
42774280Adjust the types *p_param_type (a parameter type of a function template or a
42784281type involving the "auto" type specifier) and *p_arg_type (the type of the
@@ -4295,7 +4298,10 @@ are not removed. If consider_nondeduced is non-NULL and the reason for
42954298failure is that an indefinite function matches several ways, return
42964299*consider_nondeduced TRUE. template_arg_list is used in some nonstandard
42974300modes to introduce knowledge from previous arguments; in the standard case,
4298- it is always NULL.
4301+ it is always NULL. allow_incomplete_arg is TRUE when deducing a plain
4302+ "auto" (not, for example, "auto *"). In that case an incomplete argument
4303+ type, including void, is left for deduction so the caller can diagnose the
4304+ incomplete type instead of reporting a deduction failure.
42994305*/
43004306{
43014307 a_boolean adjustment_okay = FALSE, indefinite_function_designator = FALSE;
@@ -4402,8 +4408,13 @@ it is always NULL.
44024408 if (is_incomplete_type(arg_type) && !is_managed_nullptr_type(arg_type)) {
44034409 /* Although the managed (C++/CLI) nullptr type is incomplete and
44044410 cannot be used as the type of an object, for example, the Microsoft
4405- compiler allows it as a template argument. */
4406- goto done;
4411+ compiler allows it as a template argument. A plain "auto" variable
4412+ is also allowed through: the type is deduced, and the incomplete-type
4413+ diagnostic is issued for the variable (the same diagnostic as for
4414+ decltype(auto)). "auto *" and similar forms still fail deduction. */
4415+ if (!(allow_incomplete_arg && is_template_param_type(param_type))) {
4416+ goto done;
4417+ } /* if */
44074418 } /* if */
44084419 } /* if */
44094420 /* Return the adjusted types at this point as the types that can be used to
@@ -4621,7 +4632,8 @@ deduction was successful: some cases are treated as "nondeduced contexts").
46214632 elem_operand,
46224633 templ_params, *template_arg_list,
46234634 &qc_param_type, &qc_arg_type,
4624- &consider_nondeduced)) {
4635+ &consider_nondeduced,
4636+ /*allow_incomplete_arg=*/FALSE)) {
46254637 if (consider_nondeduced) continue;
46264638 deduction_okay = FALSE;
46274639 break;
@@ -4775,7 +4787,8 @@ deduction succeeds, FALSE if it fails.
47754787 if (!adjust_deduction_pair(¶m_type, &arg_type, operand,
47764788 templ_params, *template_arg_list,
47774789 &qc_param_type, &qc_arg_type,
4778- &consider_nondeduced)) {
4790+ &consider_nondeduced,
4791+ /*allow_incomplete_arg=*/FALSE)) {
47794792 if (consider_nondeduced) {
47804793 /* The argument is an indefinite function that can match in more than
47814794 one way. Keep going without adding anything to the template
@@ -31238,7 +31251,8 @@ TRUE and FALSE is returned.
3123831251 if (!adjust_deduction_pair(&type, &arg_type, initializer_operand,
3123931252 templ_param, (a_template_arg *)NULL,
3124031253 &qc_param_type, &qc_arg_type,
31241- (a_boolean *)NULL)) {
31254+ (a_boolean *)NULL,
31255+ /*allow_incomplete_arg=*/TRUE)) {
3124231256 okay = FALSE;
3124331257 } else if (!deduce_from_one_pair(type, arg_type,
3124431258 qc_param_type, qc_arg_type,
0 commit comments