re PR c++/69078 ([C++14] function local static not initialized when only used in...
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 13 Oct 2017 17:38:50 +0000 (17:38 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 13 Oct 2017 17:38:50 +0000 (17:38 +0000)
2017-10-13  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/69078
* g++.dg/cpp1y/lambda-generic-69078-1.C: New.
* g++.dg/cpp1y/lambda-generic-69078-2.C: Likewise.

From-SVN: r253736

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C [new file with mode: 0644]

index d23143ad4964d5edfe4cf2fa48484fdbf3ebedf3..589dda59fc6e21f7d1113ae28c5f701a70fe0665 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/69078
+       * g++.dg/cpp1y/lambda-generic-69078-1.C: New.
+       * g++.dg/cpp1y/lambda-generic-69078-2.C: Likewise.
+
 2017-10-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/82274
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-1.C
new file mode 100644 (file)
index 0000000..dc045c7
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/69078
+// { dg-do run { target c++14 } }
+// { dg-options "-Wall" }
+
+#include <cassert>
+
+struct Class {
+    Class(void (*_param)()) : data(_param) {}
+    void (*data)();
+};
+
+void funUser(void (*test)(int)) {
+    test(60);
+}
+
+void user(Class& c, int i) {
+    (void)i;
+    assert (c.data);
+}
+
+void probe() {}
+
+int main() {
+    static Class instance = { probe };
+    funUser([](auto... p) {
+        user(instance, p...);
+    });
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-69078-2.C
new file mode 100644 (file)
index 0000000..318e096
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/69078
+// { dg-do run { target c++14 } }
+
+#include <cassert>
+
+template<typename F>
+void run( F &&f ) {
+  f(nullptr);
+}
+
+struct V {
+  int i;
+};
+
+int main() {
+  static V const s={2};
+  assert (s.i == 2);
+  run([](auto){
+      assert (s.i == 2);
+    });
+}