re PR c++/61362 (g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 does not compile lambda with...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 13 Sep 2017 18:18:48 +0000 (18:18 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 13 Sep 2017 18:18:48 +0000 (18:18 +0000)
2017-09-13  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/61362
* g++.dg/cpp0x/lambda/lambda-ice19.C: New.
* g++.dg/cpp0x/lambda/lambda-ice20.C: Likewise.

From-SVN: r252724

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C [new file with mode: 0644]

index f9493be90fad43ffa58ffdb61a628578ba158cac..71e2b36360453e6ed9746617085509e62f3b7bc6 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/61362
+       * g++.dg/cpp0x/lambda/lambda-ice19.C: New.
+       * g++.dg/cpp0x/lambda/lambda-ice20.C: Likewise.
+
 2017-09-13  Steve Ellcey  <sellcey@cavium.com>
 
        PR tree-optimization/80925
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice19.C
new file mode 100644 (file)
index 0000000..9fb43cd
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/61362
+// { dg-do compile { target c++11 } }
+
+struct function {
+  template<class F>
+  function(F){}
+
+  void operator()(...) {}
+};
+
+struct Node {
+  unsigned length;
+};
+
+template<typename N>
+class C {
+public:
+  unsigned longest = 0;
+  function f = [this](N node) {
+    if(node->length > this->longest) this->longest = node->length;
+  };
+};
+
+int main() {
+  Node n;
+  n.length = 5;
+  C<Node*> c;
+  c.f(&n);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice20.C
new file mode 100644 (file)
index 0000000..ae1b61b
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/61362
+// { dg-do compile { target c++11 } }
+
+template <typename>
+struct S {
+  int f{[this](){return 42;}()};
+};
+
+int main(){
+  return S<int>{}.f; // should be 42
+}