Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions flang/lib/Semantics/check-omp-loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,23 @@ using namespace Fortran::semantics::omp;

void OmpStructureChecker::HasInvalidDistributeNesting(
const parser::OpenMPLoopConstruct &x) {
bool violation{false};
const parser::OmpDirectiveName &beginName{x.BeginDir().DirName()};
if (llvm::omp::topDistributeSet.test(beginName.v)) {
// `distribute` region has to be nested
if (!CurrentDirectiveIsNested()) {
violation = true;
} else {
if (CurrentDirectiveIsNested()) {
// `distribute` region has to be strictly nested inside `teams`
if (!llvm::omp::bottomTeamsSet.test(GetContextParent().directive)) {
violation = true;
context_.Say(beginName.source,
"`DISTRIBUTE` region has to be strictly nested inside `TEAMS` "
"region."_err_en_US);
}
} else {
// If not lexically nested (orphaned), issue a warning.
context_.Say(beginName.source,
"`DISTRIBUTE` must be dynamically enclosed in a `TEAMS` "
"region."_warn_en_US);
}
}
if (violation) {
context_.Say(beginName.source,
"`DISTRIBUTE` region has to be strictly nested inside `TEAMS` "
"region."_err_en_US);
}
}
void OmpStructureChecker::HasInvalidLoopBinding(
const parser::OpenMPLoopConstruct &x) {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/OpenMP/combined-constructs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ program main
real(8) :: a(256), b(256)
N = 256

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!$omp distribute simd
do i = 1, N
a(i) = 3.14d0
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Semantics/OpenMP/do05.f90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ program omp_do
end do
!$omp end parallel do simd

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!$omp distribute parallel do
do i=1,10
if( i == 3 ) then
Expand All @@ -64,7 +64,7 @@ program omp_do
end do
!$omp end distribute parallel do

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!$omp distribute parallel do simd
do i=1,10
if( i == 3 ) then
Expand Down
6 changes: 3 additions & 3 deletions flang/test/Semantics/OpenMP/linear-iter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SUBROUTINE LINEAR_BAD(N)
!$omp end teams
!$omp end target

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!ERROR: Variable 'j' not allowed in LINEAR clause, only loop iterator can be specified in LINEAR clause of a construct combined with DISTRIBUTE
!$omp distribute simd linear(i,j)
do i = 1, N
Expand All @@ -63,7 +63,7 @@ SUBROUTINE LINEAR_BAD(N)
enddo
!$omp end distribute simd

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!ERROR: Variable 'j' not allowed in LINEAR clause, only loop iterator can be specified in LINEAR clause of a construct combined with DISTRIBUTE
!$omp distribute simd linear(i,j) collapse(1)
do i = 1, N
Expand All @@ -73,7 +73,7 @@ SUBROUTINE LINEAR_BAD(N)
enddo
!$omp end distribute simd

!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!$omp distribute simd linear(i,j) collapse(2)
do i = 1, N
do j = 1, N
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenMP/nested-distribute.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! Check OpenMP clause validity for the following directives:
! 2.10 Device constructs

subroutine f
integer :: i
!WARNING: `DISTRIBUTE` must be dynamically enclosed in a `TEAMS` region.
!$omp distribute
do i = 1, 100
print *, "hello"
end do
end subroutine
program main

real(8) :: arrayA(256), arrayB(256)
Expand Down Expand Up @@ -108,4 +117,8 @@ program main
end do
!$omp end distribute
!$omp end task

!$omp teams
call foo
!$omp end teams
end program main