From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6141 invoked by alias); 19 May 2011 13:17:23 -0000 Received: (qmail 6125 invoked by uid 22791); 19 May 2011 13:17:22 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 May 2011 13:17:02 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4JDH1us026592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 May 2011 09:17:01 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4JDH0au000923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 19 May 2011 09:17:01 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p4JDGxfi007798 for ; Thu, 19 May 2011 15:16:59 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p4JDGx5q007797 for gcc-patches@gcc.gnu.org; Thu, 19 May 2011 15:16:59 +0200 Date: Thu, 19 May 2011 14:04:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix OpenMP return checking with lambda functions (PR c++/49043) Message-ID: <20110519131659.GN17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01383.txt.bz2 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 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