re PR c++/49043 ([OpenMP & C++0x]: Compiler error when lambda-function within OpenMP...
authorJakub Jelinek <jakub@redhat.com>
Thu, 19 May 2011 13:11:56 +0000 (15:11 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 19 May 2011 13:11:56 +0000 (15:11 +0200)
PR c++/49043
* decl.c (check_omp_return): Stop searching on sk_function_parms.

* testsuite/libgomp.c++/pr49043.C: New test.

From-SVN: r173907

gcc/cp/ChangeLog
gcc/cp/decl.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/pr49043.C [new file with mode: 0644]

index 1ab211918dc9055988c58019fec078afd4b3127b..7e59b6b067acfd1b8bf5062698e9c71b8f3707fc 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/49043
+       * decl.c (check_omp_return): Stop searching on sk_function_parms.
+
        PR c++/48869
        * method.c (get_dtor, get_copy_ctor): Add COMPLAIN argument,
        pass it down to locate_fn_flags.
index e950c43e9cf19a6830bbe134722b1daa86806021..91df9ee671e00d9e047d145f8ae663055e5db0a1 100644 (file)
@@ -2833,6 +2833,8 @@ check_omp_return (void)
        error ("invalid exit from OpenMP structured block");
        return false;
       }
+    else if (b->kind == sk_function_parms)
+      break;
   return true;
 }
 
index 97382893917c4d72bfd86d8903592a613e85c87d..7d3fe227c5ea7b7476ba8f419eaef31aaf066350 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/49043
+       * testsuite/libgomp.c++/pr49043.C: New test.
+
        PR c++/48869
        * testsuite/libgomp.c++/pr48869.C: New test.
 
diff --git a/libgomp/testsuite/libgomp.c++/pr49043.C b/libgomp/testsuite/libgomp.c++/pr49043.C
new file mode 100644 (file)
index 0000000..604cfc3
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/49043
+// { dg-options "-std=c++0x" }
+// { dg-do run }
+
+extern "C" void abort ();
+
+int
+main ()
+{
+  int r = 0;
+  #pragma omp parallel for reduction (+:r)
+    for (int a = 0; a < 10; ++a)
+      {
+       auto func = [=] () { return a; };
+       r += func ();
+      }
+  if (r != 45)
+    abort ();
+}