File tree Expand file tree Collapse file tree 5 files changed +28
-16
lines changed Expand file tree Collapse file tree 5 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -127,24 +127,23 @@ using namespace Fortran::semantics::omp;
127127
128128void OmpStructureChecker::HasInvalidDistributeNesting (
129129 const parser::OpenMPLoopConstruct &x) {
130- bool violation{false };
131130 const parser::OmpDirectiveName &beginName{x.BeginDir ().DirName ()};
132131 if (llvm::omp::topDistributeSet.test (beginName.v )) {
133132 // `distribute` region has to be nested
134- if (!CurrentDirectiveIsNested ()) {
135- violation = true ;
136- } else {
133+ if (CurrentDirectiveIsNested ()) {
137134 // `distribute` region has to be strictly nested inside `teams`
138135 if (!llvm::omp::bottomTeamsSet.test (GetContextParent ().directive )) {
139- violation = true ;
136+ context_.Say (beginName.source ,
137+ " `DISTRIBUTE` region has to be strictly nested inside `TEAMS` "
138+ " region." _err_en_US);
140139 }
140+ } else {
141+ // If not lexically nested (orphaned), issue a warning.
142+ context_.Say (beginName.source ,
143+ " `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` "
144+ " region." _warn_en_US);
141145 }
142146 }
143- if (violation) {
144- context_.Say (beginName.source ,
145- " `DISTRIBUTE` region has to be strictly nested inside `TEAMS` "
146- " region." _err_en_US);
147- }
148147}
149148void OmpStructureChecker::HasInvalidLoopBinding (
150149 const parser::OpenMPLoopConstruct &x) {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ program main
77 real (8 ) :: a(256 ), b(256 )
88 N = 256
99
10- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
10+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
1111 ! $omp distribute simd
1212 do i = 1 , N
1313 a(i) = 3.14d0
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ program omp_do
4949 end do
5050 ! $omp end parallel do simd
5151
52- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
52+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
5353 ! $omp distribute parallel do
5454 do i= 1 ,10
5555 if ( i == 3 ) then
@@ -64,7 +64,7 @@ program omp_do
6464 end do
6565 ! $omp end distribute parallel do
6666
67- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
67+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
6868 ! $omp distribute parallel do simd
6969 do i= 1 ,10
7070 if ( i == 3 ) then
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ SUBROUTINE LINEAR_BAD(N)
5353 ! $omp end teams
5454 ! $omp end target
5555
56- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
56+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
5757 ! ERROR: Variable 'j' not allowed in LINEAR clause, only loop iterator can be specified in LINEAR clause of a construct combined with DISTRIBUTE
5858 ! $omp distribute simd linear(i,j)
5959 do i = 1 , N
@@ -63,7 +63,7 @@ SUBROUTINE LINEAR_BAD(N)
6363 enddo
6464 ! $omp end distribute simd
6565
66- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
66+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
6767 ! ERROR: Variable 'j' not allowed in LINEAR clause, only loop iterator can be specified in LINEAR clause of a construct combined with DISTRIBUTE
6868 ! $omp distribute simd linear(i,j) collapse(1)
6969 do i = 1 , N
@@ -73,7 +73,7 @@ SUBROUTINE LINEAR_BAD(N)
7373 enddo
7474 ! $omp end distribute simd
7575
76- ! ERROR : `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
76+ ! WARNING : `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
7777 ! $omp distribute simd linear(i,j) collapse(2)
7878 do i = 1 , N
7979 do j = 1 , N
Original file line number Diff line number Diff line change 11! RUN: %python %S/../test_errors.py %s %flang -fopenmp
22! Check OpenMP clause validity for the following directives:
33! 2.10 Device constructs
4+
5+ subroutine f
6+ integer :: i
7+ ! WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
8+ ! $omp distribute
9+ do i = 1 , 100
10+ print * , " hello"
11+ end do
12+ end subroutine
413program main
514
615 real (8 ) :: arrayA(256 ), arrayB(256 )
@@ -108,4 +117,8 @@ program main
108117 end do
109118 ! $omp end distribute
110119 ! $omp end task
120+
121+ ! $omp teams
122+ call foo
123+ ! $omp end teams
111124end program main
You can’t perform that action at this time.
0 commit comments