aboutsummaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorArnamoy Bhattacharyya <arnamoy.bhattacharyya@huawei.com>2021-04-13 13:56:43 -0400
committerArnamoy Bhattacharyya <arnamoy10@gmail.com>2021-04-13 13:59:18 -0400
commit162b463d85d3b6d253479b2b3b87fca786e61258 (patch)
tree683aff6d0f6bc90e195ab8451558aade0b3cb7b1 /flang
parent[MemorySSA] Add test for PR49859. (diff)
downloadllvm-project-162b463d85d3b6d253479b2b3b87fca786e61258.tar.gz
llvm-project-162b463d85d3b6d253479b2b3b87fca786e61258.tar.bz2
llvm-project-162b463d85d3b6d253479b2b3b87fca786e61258.zip
[flang][OpenMP] Modify semantic check for nesting of `ordered` regions to include `close` nesting check.
Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D100222
Diffstat (limited to 'flang')
-rw-r--r--flang/lib/Semantics/check-omp-structure.cpp3
-rw-r--r--flang/test/Semantics/omp-ordered-simd.f9050
2 files changed, 51 insertions, 2 deletions
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index dcb70015d5d8..d05d663ec76f 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -394,8 +394,7 @@ void OmpStructureChecker::CheckIfDoOrderedClause(
}
// Other disallowed nestings, these directives do not support
// ordered clause in them, so no need to check
- else if (llvm::omp::nestedOrderedErrSet.test(
- GetContextParent().directive)) {
+ else if (IsCloselyNestedRegion(llvm::omp::nestedOrderedErrSet)) {
context_.Say(blkDirective.source,
"`ORDERED` region may not be closely nested inside of "
"`CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region."_err_en_US);
diff --git a/flang/test/Semantics/omp-ordered-simd.f90 b/flang/test/Semantics/omp-ordered-simd.f90
index d597191650e7..5a3760ea604c 100644
--- a/flang/test/Semantics/omp-ordered-simd.f90
+++ b/flang/test/Semantics/omp-ordered-simd.f90
@@ -92,4 +92,54 @@ SUBROUTINE ORDERED_BAD(N)
END DO
!$OMP END TASKLOOP
+ !$OMP CRITICAL
+ C = C - A * B
+ !$OMP MASTER
+ DO I = 1,N
+ !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
+ !$OMP ORDERED
+ CALL WORK(I)
+ !$OMP END ORDERED
+ END DO
+ !$OMP END MASTER
+ !$OMP END CRITICAL
+
+ !$OMP ORDERED
+ C = C - A * B
+ !$OMP MASTER
+ DO I = 1,N
+ !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
+ !$OMP ORDERED
+ CALL WORK(I)
+ !$OMP END ORDERED
+ END DO
+ !$OMP END MASTER
+ !$OMP END ORDERED
+
+ !$OMP TASK
+ C = C - A * B
+ !$OMP MASTER
+ DO I = 1,N
+ !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
+ !$OMP ORDERED
+ CALL WORK(I)
+ !$OMP END ORDERED
+ END DO
+ !$OMP END MASTER
+ !$OMP END TASK
+
+ !$OMP TASKLOOP
+ DO J= 1,N
+ C = C - A * B
+ !$OMP MASTER
+ DO I = 1,N
+ !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
+ !$OMP ORDERED
+ CALL WORK(I)
+ !$OMP END ORDERED
+ END DO
+ !$OMP END MASTER
+ END DO
+ !$OMP END TASKLOOP
+
END SUBROUTINE ORDERED_BAD