+2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61088
+ * lambda.c (add_capture): Enforce that capture by value requires
+ complete type.
+ * typeck2.c (cxx_incomplete_type_inform): Early return if
+ TYPE_MAIN_DECL is null.
+
2014-05-21 Jonathan Wakely <jwakely@redhat.com>
PR c/61271
initializer = build_x_compound_expr_from_list (initializer, ELK_INIT,
tf_warning_or_error);
type = TREE_TYPE (initializer);
+ if (type == error_mark_node)
+ return error_mark_node;
+
if (array_of_runtime_bound_p (type))
{
vla = true;
error ("cannot capture %qE by reference", initializer);
}
else
- /* Capture by copy requires a complete type. */
- type = complete_type (type);
+ {
+ /* Capture by copy requires a complete type. */
+ type = complete_type (type);
+ if (!dependent_type_p (type) && !COMPLETE_TYPE_P (type))
+ {
+ error ("capture by copy of incomplete type %qT", type);
+ cxx_incomplete_type_inform (type);
+ return error_mark_node;
+ }
+ }
}
/* Add __ to the beginning of the field name so that user code
void
cxx_incomplete_type_inform (const_tree type)
{
+ if (!TYPE_MAIN_DECL (type))
+ return;
+
location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
tree ptype = strip_top_quals (CONST_CAST_TREE (type));
+2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61088
+ * g++.dg/cpp0x/lambda/lambda-ice13.C: New.
+ * g++.dg/cpp0x/lambda/lambda-ice7.C: Adjust.
+
2014-05-22 Xinliang David Li <davidxl@google.com>
* g++.dg/ipa/devirt-15.C: Fix expected message.
--- /dev/null
+// PR c++/61088
+// { dg-do compile { target c++11 } }
+
+void f()
+{
+ typedef void (*X) ();
+ X x[] = { [x](){} }; // { dg-error "incomplete type" }
+}
+
+void g()
+{
+ typedef void (X) ();
+ X x[] = { [x](){} }; // { dg-error "array of functions|not declared" }
+}