init = tsubst_expr (init, args, complain, in_decl, false);
- if (!init && TREE_TYPE (decl) != error_mark_node)
- {
- /* If we had an initializer but it
- instantiated to nothing,
- value-initialize the object. This will
- only occur when the initializer was a
- pack expansion where the parameter packs
- used in that expansion were of length
- zero. */
- init = build_value_init (TREE_TYPE (decl),
- complain);
- if (TREE_CODE (init) == AGGR_INIT_EXPR)
- init = get_target_expr_sfinae (init, complain);
- if (TREE_CODE (init) == TARGET_EXPR)
- TARGET_EXPR_DIRECT_INIT_P (init) = true;
+ tree type = TREE_TYPE (decl);
+
+ if (!init && type != error_mark_node)
+ {
+ if (tree auto_node = type_uses_auto (type))
+ {
+ if (!CLASS_PLACEHOLDER_TEMPLATE (auto_node))
+ {
+ if (complain & tf_error)
+ error ("initializer for %q#D expands to an empty list "
+ "of expressions", decl);
+ return error_mark_node;
+ }
+ }
+ else if (!dependent_type_p (type))
+ {
+ /* If we had an initializer but it
+ instantiated to nothing,
+ value-initialize the object. This will
+ only occur when the initializer was a
+ pack expansion where the parameter packs
+ used in that expansion were of length
+ zero. */
+ init = build_value_init (type, complain);
+ if (TREE_CODE (init) == AGGR_INIT_EXPR)
+ init = get_target_expr_sfinae (init, complain);
+ if (TREE_CODE (init) == TARGET_EXPR)
+ TARGET_EXPR_DIRECT_INIT_P (init) = true;
+ }
}
return init;
{
start_lambda_scope (decl);
DECL_INITIAL (decl) =
- tsubst_expr (DECL_INITIAL (code_pattern), args,
- tf_error, DECL_TI_TEMPLATE (decl),
- /*integral_constant_expression_p=*/false);
+ tsubst_init (DECL_INITIAL (code_pattern), decl, args,
+ tf_error, DECL_TI_TEMPLATE (decl));
finish_lambda_scope ();
if (VAR_HAD_UNKNOWN_BOUND (decl))
TREE_TYPE (decl) = tsubst (TREE_TYPE (code_pattern), args,