File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -2285,14 +2285,17 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
22852285 }
22862286
22872287 auto checkPerfectNest = [&, this ]() {
2288- auto blockSize = block.size ();
2289- if (blockSize <= 1 )
2288+ if (block.empty ())
22902289 return ;
2290+ auto last = block.end ();
2291+ --last;
22912292
2292- if (parser::Unwrap<parser::ContinueStmt>(x))
2293- blockSize -= 1 ;
2293+ // A trailing CONTINUE is not considered part of the loop body
2294+ if (parser::Unwrap<parser::ContinueStmt>(*last))
2295+ --last;
22942296
2295- if (blockSize <= 1 )
2297+ // In a perfectly nested loop, the nested loop must be the only statement
2298+ if (last == block.begin ())
22962299 return ;
22972300
22982301 // Non-perfectly nested loop
Original file line number Diff line number Diff line change 1+ ! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
2+
3+ program wsloop_collapse_continue
4+ integer i, j
5+
6+ ! CHECK: omp.wsloop {{.*}} {
7+ ! CHECK: omp.loop_nest ({{.*}}) : i32 = ({{.*}}) to ({{.*}}) inclusive step ({{.*}}) collapse(2) {
8+ ! $omp do collapse(2)
9+ do 50 i = 1 , 42
10+ do 51 j = 1 , 84
11+ ! CHECK: fir.call @_FortranAioOutputInteger32(
12+ print * , i
13+ ! CHECK: fir.call @_FortranAioOutputInteger32(
14+ print * , j
15+ 51 continue
16+ 50 continue
17+ ! $omp end do
18+
19+ end program wsloop_collapse_continue
Original file line number Diff line number Diff line change @@ -61,7 +61,6 @@ program omp
6161 ! $omp end do
6262
6363
64- ! ERROR: Canonical loop nest must be perfectly nested.
6564 ! ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
6665 ! $omp do collapse(3)
6766 do 60 i= 2 ,200 ,2
Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ program omp
5959 ! $omp end do
6060
6161
62- ! ERROR: Canonical loop nest must be perfectly nested.
6362 ! ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
6463 ! $omp do collapse(3)
6564 do 60 i= 1 ,10
You can’t perform that action at this time.
0 commit comments