@@ -2785,9 +2785,8 @@ decl_jump_unsafe (tree decl)
|| type == error_mark_node)
return 0;
- type = strip_array_types (type);
-
- if (DECL_NONTRIVIALLY_INITIALIZED_P (decl))
+ if (DECL_NONTRIVIALLY_INITIALIZED_P (decl)
+ || variably_modified_type_p (type, NULL_TREE))
return 2;
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
new file mode 100644
@@ -0,0 +1,23 @@
+// PR c++/21113
+// { dg-options "" }
+
+void
+f (int n)
+{
+ goto label; // { dg-error "from here" }
+ int a[n]; // { dg-error "crosses initialization" }
+label: // { dg-error "jump to label" }
+ ;
+}
+
+void
+g (int n)
+{
+ switch (1)
+ {
+ case 1:
+ int (*a)[n]; // { dg-error "crosses initialization" }
+ default: // { dg-error "jump to case label" }
+ ;
+ }
+}