diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1ab211918dc9055988c58019fec078afd4b3127b..7e59b6b067acfd1b8bf5062698e9c71b8f3707fc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e950c43e9cf19a6830bbe134722b1daa86806021..91df9ee671e00d9e047d145f8ae663055e5db0a1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
 }
 
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 97382893917c4d72bfd86d8903592a613e85c87d..7d3fe227c5ea7b7476ba8f419eaef31aaf066350 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -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
index 0000000000000000000000000000000000000000..604cfc30dadd8452eb6ce061414b4787cef3f72a
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr49043.C
@@ -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 ();
+}