re PR c++/61402 (-Wsequence-point doesn't notice unsequenced lambda init and function...
authorJason Merrill <jason@redhat.com>
Fri, 12 Dec 2014 16:43:16 +0000 (11:43 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 12 Dec 2014 16:43:16 +0000 (11:43 -0500)
PR c++/61402
* lambda.c (add_capture): Don't pass a dependent type to
variably_modified_type_p.

From-SVN: r218680

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

index 53bf2f5981c2bcb2fd62b1631bc0299c1a35c7f2..1809b26a0109379dcc78768c4169db1d86a25a13 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/61402
+       * lambda.c (add_capture): Don't pass a dependent type to
+       variably_modified_type_p.
+
 2014-12-11  Jason Merrill  <jason@redhat.com>
 
        Remove N3639 "array of runtime length" from -std=c++14.
index 9eb9200632326bc5f3c13ef8184402ea681175bd..3da28e5688315721aa8d886bab88abac99186eb4 100644 (file)
@@ -483,7 +483,8 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
                                          NULL_TREE, array_type_nelts (type));
       type = vla_capture_type (type);
     }
-  else if (variably_modified_type_p (type, NULL_TREE))
+  else if (!dependent_type_p (type)
+          && variably_modified_type_p (type, NULL_TREE))
     {
       error ("capture of variable-size type %qT that is not an N3639 array "
             "of runtime bound", type);
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C
new file mode 100644 (file)
index 0000000..f7525d8
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/61402
+// { dg-do run { target c++14 } }
+
+extern "C" void abort();
+
+template<typename T>
+void foo(T t) {
+  auto test = [ i = ++t ](T v) {
+    if (i != v)
+      abort();
+  };
+  test(t);
+}
+
+int main(){
+  foo(3.14f);
+  foo(0);
+  foo('a');
+  foo(false);
+}