2013-06-06 Jason Merrill <jason@redhat.com>
+ PR c++/55520
+ * semantics.c (add_capture): Diagnose capture of variable-size
+ type that is not a C++1y array of runtime bound.
+
* decl.c (grokdeclarator): Keep a decl with error type.
(grokfield, grokbitfield): Likewise.
* pt.c (instantiate_class_template_1): Likewise.
nelts_field, array_type_nelts (type));
type = ctype;
}
+ else if (variably_modified_type_p (type, NULL_TREE))
+ {
+ error ("capture of variable-size type %qT that is not a C++1y array "
+ "of runtime bound", type);
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && variably_modified_type_p (TREE_TYPE (type), NULL_TREE))
+ inform (input_location, "because the array element type %qT has "
+ "variable size", TREE_TYPE (type));
+ }
else if (by_reference_p)
{
type = build_reference_type (type);
--- /dev/null
+// PR c++/55520
+// { dg-options "-Wno-vla" }
+// { dg-require-effective-target c++11 }
+
+int main(int argc, char** argv)
+{
+ int x[1][argc];
+
+ [&x](int i) { // { dg-error "variable.size" }
+ x[0][i] = 0; // { dg-prune-output "assignment" }
+ }(5);
+}