@@ -1386,8 +1386,8 @@ gfc_trans_omp_do (gfc_code *code, stmtbl
/* Put these labels where they can be found later. */
- code->block->cycle_label = cycle_label;
- code->block->exit_label = NULL_TREE;
+ code->cycle_label = cycle_label;
+ code->exit_label = NULL_TREE;
/* Main loop body. */
tmp = gfc_trans_omp_code (code->block->next, true);
@@ -0,0 +1,22 @@
+! PR fortran/45597
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+subroutine foo(n)
+ integer :: i, n(6)
+ !$omp parallel do default(none) shared(n)
+ do i = 1, 6
+ if (n(i).gt.0) cycle
+ end do
+end subroutine
+subroutine bar(n)
+ integer :: i, j, k, n(6, 6, 6)
+ !$omp parallel do default(none) shared(n) collapse(3)
+ do i = 1, 6
+ do j = 1, 6
+ do k = 1, 6
+ if (n(i, j, k).gt.0) cycle
+ end do
+ end do
+ end do
+end subroutine