Patchwork [committed] Fix handling of invalid omp do collapse (PR fortran/45595)

login
register
mail settings
Submitter Jakub Jelinek
Date Sept. 8, 2010, 5:21 p.m.
Message ID <20100908172118.GP1269@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/64185/
State New
Headers show

Comments

Jakub Jelinek - Sept. 8, 2010, 5:21 p.m.
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  <jakub@redhat.com>

	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

Patch

--- 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