From patchwork Wed Sep 8 17:21:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [committed] Fix handling of invalid omp do collapse (PR fortran/45595) Date: Wed, 08 Sep 2010 07:21:18 -0000 From: Jakub Jelinek X-Patchwork-Id: 64185 Message-Id: <20100908172118.GP1269@tyan-ft48-01.lab.bos.redhat.com> To: gcc-patches@gcc.gnu.org Cc: fortran@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