public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix OpenMP return checking with lambda functions (PR c++/49043)
@ 2011-05-19 14:04 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2011-05-19 14:04 UTC (permalink / raw)
  To: gcc-patches

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  <jakub@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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-19 13:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 14:04 [PATCH] Fix OpenMP return checking with lambda functions (PR c++/49043) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).