Hi!

return is just fine in lambda functions and in methods in classes declared
inside of OpenMP regions.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk and 4.6 branch.

2011-05-19  Jakub Jelinek  <ja...@redhat.com>

        PR c++/49043
        * decl.c (check_omp_return): Stop searching on sk_function_parms.

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

--- gcc/cp/decl.c.jj    2011-05-17 13:32:18.000000000 +0200
+++ gcc/cp/decl.c       2011-05-19 10:27:46.000000000 +0200
@@ -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;
 }
 
--- libgomp/testsuite/libgomp.c++/pr49043.C.jj  2011-05-19 10:31:57.000000000 
+0200
+++ libgomp/testsuite/libgomp.c++/pr49043.C     2011-05-19 10:22:47.000000000 
+0200
@@ -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 ();
+}

        Jakub

Reply via email to