re PR c++/57408 (lambda, Variable length arrays, thread, internal compiler error...
authorJason Merrill <jason@redhat.com>
Thu, 27 Jun 2013 02:35:39 +0000 (22:35 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 27 Jun 2013 02:35:39 +0000 (22:35 -0400)
PR c++/57408
* semantics.c (add_capture): Set type to error_mark_node after
error.

From-SVN: r200449

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp1y/vla9.C [new file with mode: 0644]

index bd82693722cfae4669bb1fa8f58fc82ccf6e779c..3be2f1e715d0c54b4addecf200719b19412ccdcb 100644 (file)
@@ -1,3 +1,9 @@
+2013-06-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/57408
+       * semantics.c (add_capture): Set type to error_mark_node after
+       error.
+
 2013-06-25  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        PR c++/57640
index 0a460a42544c47e78b3c202b5ed80175c3b28d14..4c76b80d0cd5ac38b76fe95679ed0c993e349477 100644 (file)
@@ -9521,6 +9521,7 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p,
          && variably_modified_type_p (TREE_TYPE (type), NULL_TREE))
        inform (input_location, "because the array element type %qT has "
                "variable size", TREE_TYPE (type));
+      type = error_mark_node;
     }
   else if (by_reference_p)
     {
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla9.C b/gcc/testsuite/g++.dg/cpp1y/vla9.C
new file mode 100644 (file)
index 0000000..ea5c4d8
--- /dev/null
@@ -0,0 +1,31 @@
+// PR c++/57408
+// { dg-options "-std=c++1y -pedantic-errors" }
+
+template<typename Callable>
+  struct Impl
+  {
+    Callable func;
+    Impl(Callable f) : func(f) { }
+    virtual void run() { func(); }
+  };
+
+template<typename Callable>
+void call(Callable f)
+  {
+    Impl<Callable>(f).run();
+  }
+
+extern "C" int printf(const char*, ...);
+
+int main(){
+    int y = 2;
+    float fa[2][y];        // { dg-error "array of array of runtime bound" }
+    fa[0][0]=0.8;
+    fa[0][1]=1.8;
+    auto fx=[&](){
+        for(int c=0; c<2; c++){
+            printf("use me", fa[0][c]);        // { dg-error "capture of variable-size type" }
+        }
+    };
+    call(fx);
+}