From ea93a47bc825a409079665551203aa194e71fc18 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Thu, 19 May 2011 15:11:56 +0200
Subject: [PATCH] re PR c++/49043 ([OpenMP & C++0x]: Compiler error when
 lambda-function within OpenMP loop)

	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                        |  3 +++
 gcc/cp/decl.c                           |  2 ++
 libgomp/ChangeLog                       |  3 +++
 libgomp/testsuite/libgomp.c++/pr49043.C | 19 +++++++++++++++++++
 4 files changed, 27 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.c++/pr49043.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1ab211918dc9..7e59b6b067ac 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 e950c43e9cf1..91df9ee671e0 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 97382893917c..7d3fe227c5ea 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 000000000000..604cfc30dadd
--- /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 ();
+}
-- 
GitLab