From patchwork Wed Sep 8 17:21:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 64185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1BFDEB6EFF for ; Thu, 9 Sep 2010 03:21:02 +1000 (EST) Received: (qmail 23831 invoked by alias); 8 Sep 2010 17:20:59 -0000 Received: (qmail 23814 invoked by uid 22791); 8 Sep 2010 17:20:58 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, 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; Wed, 08 Sep 2010 17:20:53 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o88HKpda014235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 Sep 2010 13:20:51 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o88HKomd010044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Sep 2010 13:20:51 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o88HLJk0018846; Wed, 8 Sep 2010 19:21:19 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o88HLIxa018844; Wed, 8 Sep 2010 19:21:18 +0200 Date: Wed, 8 Sep 2010 19:21:18 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: fortran@gcc.gnu.org Subject: [committed] Fix handling of invalid omp do collapse (PR fortran/45595) Message-ID: <20100908172118.GP1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! If there are no statements in do stmt and collapse is too high, f951 segfaults. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, will commit to 4.5/4.4 RSN. 2010-09-08 Jakub Jelinek PR fortran/45595 * openmp.c (resolve_omp_do): Report not enough do loops for collapse even if block->next is NULL. * gfortran.dg/gomp/pr45595.f90: New test. Jakub --- gcc/fortran/openmp.c.jj 2010-06-10 19:32:11.000000000 +0200 +++ gcc/fortran/openmp.c 2010-09-08 15:56:52.000000000 +0200 @@ -1516,7 +1516,8 @@ resolve_omp_do (gfc_code *code) break; } do_code = do_code->next; - if (do_code->op != EXEC_DO && do_code->op != EXEC_DO_WHILE) + if (do_code == NULL + || (do_code->op != EXEC_DO && do_code->op != EXEC_DO_WHILE)) { gfc_error ("not enough DO loops for collapsed !$OMP DO at %L", &code->loc); --- gcc/testsuite/gfortran.dg/gomp/pr45595.f90.jj 2010-09-08 15:59:21.000000000 +0200 +++ gcc/testsuite/gfortran.dg/gomp/pr45595.f90 2010-09-08 15:58:01.000000000 +0200 @@ -0,0 +1,10 @@ +! PR fortran/45595 +! { dg-do compile } +! { dg-options "-fopenmp" } + +subroutine foo(l,u) + integer :: k,l,u + !$omp parallel do shared(l,u) collapse(3) ! { dg-error "not enough DO loops" } + do k = l,u + end do +end subroutine