* lambda.c (add_capture): Leave a pack expansion in a TREE_LIST.
(build_lambda_object): Call build_x_compound_expr_from_list.
* pt.c (tsubst) [DECLTYPE_TYPE]: Likewise.
From-SVN: r238733
2016-07-25 Jason Merrill <jason@redhat.com>
+ PR c++/71837
+ * lambda.c (add_capture): Leave a pack expansion in a TREE_LIST.
+ (build_lambda_object): Call build_x_compound_expr_from_list.
+ * pt.c (tsubst) [DECLTYPE_TYPE]: Likewise.
+
PR c++/71833
PR c++/54440
* pt.c (coerce_template_parameter_pack): Fix logic for
goto out;
}
+ if (TREE_CODE (val) == TREE_LIST)
+ val = build_x_compound_expr_from_list (val, ELK_INIT,
+ tf_warning_or_error);
+
if (DECL_P (val))
mark_used (val);
variadic = true;
}
- if (TREE_CODE (initializer) == TREE_LIST)
+ if (TREE_CODE (initializer) == TREE_LIST
+ /* A pack expansion might end up with multiple elements. */
+ && !PACK_EXPANSION_P (TREE_VALUE (initializer)))
initializer = build_x_compound_expr_from_list (initializer, ELK_INIT,
tf_warning_or_error);
type = TREE_TYPE (initializer);
/*function_p*/false,
/*integral_constant_expression*/false);
+ if (DECLTYPE_FOR_INIT_CAPTURE (t))
+ {
+ if (type == NULL_TREE)
+ {
+ if (complain & tf_error)
+ error ("empty initializer in lambda init-capture");
+ type = error_mark_node;
+ }
+ else if (TREE_CODE (type) == TREE_LIST)
+ type = build_x_compound_expr_from_list (type, ELK_INIT, complain);
+ }
+
--cp_unevaluated_operand;
--c_inhibit_evaluation_warnings;
--- /dev/null
+// PR c++/71837
+// { dg-do compile { target c++14 } }
+
+template < typename ... Ts > void f (Ts ... args)
+{
+ [ts (args ...)] { return ts; } ();
+}
+
+int main ()
+{
+ f (0);
+ return 0;
+}
--- /dev/null
+// PR c++/71837
+// { dg-do compile { target c++14 } }
+
+template < typename ... Ts > void f (Ts ... args)
+{
+ [ts (args ...)] { return ts; } (); // { dg-error "" }
+}
+
+int main ()
+{
+ f (); // { dg-message "required" }
+ f (1,2); // { dg-message "required" }
+ return 0;
+}