Skip to content

Commit f1c260d

Browse files
committed
Fix unparse and add a test for nested loop constructs.
1 parent bdead72 commit f1c260d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,6 +2926,8 @@ class UnparseVisitor {
29262926
Walk(std::get<OmpBeginLoopDirective>(x.t));
29272927
Put("\n");
29282928
EndOpenMP();
2929+
Walk(
2930+
std::get<std::optional<common::Indirection<OpenMPLoopConstruct>>>(x.t));
29292931
Walk(std::get<std::optional<DoConstruct>>(x.t));
29302932
Walk(std::get<std::optional<OmpEndLoopDirective>>(x.t));
29312933
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
! RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=51 %s | FileCheck --ignore-case %s
2+
! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=51 %s | FileCheck --check-prefix="PARSE-TREE" %s
3+
4+
subroutine openmp_do_tiles(x)
5+
6+
integer, intent(inout)::x
7+
8+
9+
!CHECK: !$omp do
10+
!CHECK: !$omp tile sizes
11+
!$omp do
12+
!$omp tile sizes(2)
13+
!CHECK: do
14+
do x = 1, 100
15+
call F1()
16+
!CHECK: end do
17+
end do
18+
!CHECK: !$omp end tile
19+
!$omp end tile
20+
!$omp end do
21+
22+
!PARSE-TREE:| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
23+
!PARSE-TREE:| | | OmpBeginLoopDirective
24+
!PARSE-TREE:| | | OpenMPLoopConstruct
25+
!PARSE-TREE:| | | | OmpBeginLoopDirective
26+
!PARSE-TREE:| | | | | OmpLoopDirective -> llvm::omp::Directive = tile
27+
!PARSE-TREE:| | | | | OmpClauseList -> OmpClause -> Sizes -> Scalar -> Integer -> Expr = '2_4'
28+
!PARSE-TREE: | | | | DoConstruct
29+
END subroutine openmp_do_tiles

0 commit comments

Comments
 (0)