PR c++/84560 - ICE capturing multi-dimensional VLA.
authorJason Merrill <jason@redhat.com>
Tue, 27 Feb 2018 02:45:56 +0000 (21:45 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Feb 2018 02:45:56 +0000 (21:45 -0500)
* tree.c (array_of_runtime_bound_p): False if the element is
variably-modified.

From-SVN: r258023

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C [new file with mode: 0644]

index e34611324c44beb56123521092e47930a48d664a..dd35f1bda5242cf5f9cbfaf4b2592aca544b6e0b 100644 (file)
@@ -1,5 +1,9 @@
 2018-02-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/84560 - ICE capturing multi-dimensional VLA.
+       * tree.c (array_of_runtime_bound_p): False if the element is
+       variably-modified.
+
        PR c++/84441 - ICE with base initialized from ?:
        * call.c (unsafe_copy_elision_p): Handle COND_EXPR.
 
index 41d9002d8f946636614b8bac4eedec2e71aa5d02..9b9e36a1173f999abd4da555c55e7109473410a9 100644 (file)
@@ -1043,6 +1043,8 @@ array_of_runtime_bound_p (tree t)
 {
   if (!t || TREE_CODE (t) != ARRAY_TYPE)
     return false;
+  if (variably_modified_type_p (TREE_TYPE (t), NULL_TREE))
+    return false;
   tree dom = TYPE_DOMAIN (t);
   if (!dom)
     return false;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla2.C
new file mode 100644 (file)
index 0000000..d4de131
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/84560
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+void f() {
+  int n = 1;
+  int m = 1;
+  int d[n][m];
+  [&]() {
+    return d[1];               // { dg-error "variabl" }
+  }();
+}