From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix OpenMP return checking with lambda functions (PR c++/49043)
Date: Thu, 19 May 2011 14:04:00 -0000 [thread overview]
Message-ID: <20110519131659.GN17079@tyan-ft48-01.lab.bos.redhat.com> (raw)
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
reply other threads:[~2011-05-19 13:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110519131659.GN17079@tyan-ft48-01.lab.bos.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).