* g++.dg/cpp1z/constexpr-lambda22.C: New test,
authorMarek Polacek <polacek@redhat.com>
Thu, 1 Nov 2018 18:29:44 +0000 (18:29 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 1 Nov 2018 18:29:44 +0000 (18:29 +0000)
From-SVN: r265725

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C [new file with mode: 0644]

index 8ac78052a156d0a0f06f34d1772aaa40540687e5..e85b37cdb8a7a501fbeaeca5deae5ff782dfba9f 100644 (file)
@@ -1,3 +1,7 @@
+2018-11-01  Marek Polacek  <polacek@redhat.com>
+
+       * g++.dg/cpp1z/constexpr-lambda22.C: New test,
+
 2018-11-01  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
        * gcc.dg/tree-ssa/cunroll-13.c: Add missing cast from literal to int32.
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda22.C
new file mode 100644 (file)
index 0000000..fcb6ff9
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options -std=c++17 }
+
+#define SA(X) static_assert((X),#X)
+
+template<typename>
+constexpr int
+foo ()
+{
+  constexpr int a[] = { 1, 2, 3, 4, 5 };
+  int i = 0;
+  auto j = [&] {
+    for (auto x : a)
+      i++;
+    return i;
+  }();
+  return j;
+}
+
+SA (foo<int>() == 5);