aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-08-04 18:17:04 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-08-04 18:17:53 +0200
commit57dd9f3bfca8bb752c630431dc033c761e2ad382 (patch)
tree804b391fc51456adb28b827fd4c0a07c371c2ee0 /gcc
parent73b7cb6dfcad1b3e7538ddc2b40cc327d2fe501a (diff)
downloadgcc-57dd9f3bfca8bb752c630431dc033c761e2ad382.zip
gcc-57dd9f3bfca8bb752c630431dc033c761e2ad382.tar.gz
gcc-57dd9f3bfca8bb752c630431dc033c761e2ad382.tar.bz2
Fortran/OpenMP: Fix detecting not perfectly nested loops
gcc/fortran/ChangeLog: * openmp.c (resolve_omp_do): Detect not perfectly nested loop with innermost collapse. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/collapse1.f90: Add dg-error. * gfortran.dg/gomp/collapse2.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/openmp.c4
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/collapse1.f902
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/collapse2.f9032
3 files changed, 34 insertions, 4 deletions
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index ec11620..f402feb 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -6202,8 +6202,6 @@ resolve_omp_do (gfc_code *code)
do_code2 = do_code2->block->next;
}
}
- if (i == collapse)
- break;
for (c = do_code->next; c; c = c->next)
if (c->op != EXEC_NOP && c->op != EXEC_CONTINUE)
{
@@ -6211,7 +6209,7 @@ resolve_omp_do (gfc_code *code)
name, &c->loc);
break;
}
- if (c)
+ if (i == collapse || c)
break;
do_code = do_code->block;
if (do_code->op != EXEC_DO && do_code->op != EXEC_DO_WHILE)
diff --git a/gcc/testsuite/gfortran.dg/gomp/collapse1.f90 b/gcc/testsuite/gfortran.dg/gomp/collapse1.f90
index f16a780..1a06eab 100644
--- a/gcc/testsuite/gfortran.dg/gomp/collapse1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/collapse1.f90
@@ -31,7 +31,7 @@ subroutine collapse1
do i = 1, 3
do j = 4, 6
end do
- k = 4
+ k = 4 ! { dg-error "loops not perfectly nested" }
end do
!$omp parallel do collapse(2)
do i = 1, 3
diff --git a/gcc/testsuite/gfortran.dg/gomp/collapse2.f90 b/gcc/testsuite/gfortran.dg/gomp/collapse2.f90
new file mode 100644
index 0000000..1ab934e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/collapse2.f90
@@ -0,0 +1,32 @@
+program p
+ integer :: i, j, k
+ real :: x
+ !$omp parallel do collapse(3)
+ do i = 1, 8
+ do j = 1, 8
+ do k = 1, 8
+ end do
+ x = 5 ! { dg-error "loops not perfectly nested" }
+ end do
+ end do
+ !$omp parallel do ordered(3)
+ do i = 1, 8
+ do j = 1, 8
+ do k = 1, 8
+ end do
+ end do
+ x = 5 ! { dg-error "loops not perfectly nested" }
+ end do
+ !$omp parallel do collapse(2) ! { dg-error "not enough DO loops for collapsed" }
+ do i = 1, 8
+ x = 5
+ do j = 1, 8
+ end do
+ end do
+ !$omp parallel do ordered(2) ! { dg-error "not enough DO loops for collapsed" }
+ do i = 1, 8
+ x = 5
+ do j = 1, 8
+ end do
+ end do
+end