Skip to content

Commit 9ad3e83

Browse files
committed
Address review comments and rebase.
1 parent 17944a9 commit 9ad3e83

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,7 @@ void OmpStructureChecker::CheckTargetNest(const parser::OpenMPConstruct &c) {
824824
std::get<parser::OmpBeginBlockDirective>(c.t)};
825825
const auto &beginDir{
826826
std::get<parser::OmpBlockDirective>(beginBlockDir.t)};
827-
if (beginDir.v == llvm::omp::Directive::OMPD_target_data ||
828-
llvm::omp::allTargetSet.test(beginDir.v)) {
827+
if (beginDir.v == llvm::omp::Directive::OMPD_target_data) {
829828
eligibleTarget = false;
830829
ineligibleTargetDir = beginDir.v;
831830
}
@@ -849,11 +848,21 @@ void OmpStructureChecker::CheckTargetNest(const parser::OpenMPConstruct &c) {
849848
},
850849
c.u);
851850
},
851+
[&](const parser::OpenMPLoopConstruct &c) {
852+
const auto &beginLoopDir{
853+
std::get<parser::OmpBeginLoopDirective>(c.t)};
854+
const auto &beginDir{
855+
std::get<parser::OmpLoopDirective>(beginLoopDir.t)};
856+
if (llvm::omp::allTargetSet.test(beginDir.v)) {
857+
eligibleTarget = false;
858+
ineligibleTargetDir = beginDir.v;
859+
}
860+
},
852861
[&](const auto &c) {},
853862
},
854863
c.u);
855864
if (!eligibleTarget) {
856-
context_.Warn(common::UsageWarning::Portability,
865+
context_.Warn(common::UsageWarning::OpenMPUsage,
857866
parser::FindSourceLocation(c),
858867
"If %s directive is nested inside TARGET region, the behaviour is unspecified"_port_en_US,
859868
parser::ToUpperCaseLetters(
@@ -1067,28 +1076,14 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) {
10671076
CheckMatching<parser::OmpBlockDirective>(beginDir, endDir);
10681077

10691078
PushContextAndClauseSets(beginDir.source, beginDir.v);
1070-
if (GetContext().directive == llvm::omp::Directive::OMPD_target) {
1079+
if (llvm::omp::allTargetSet.test(GetContext().directive)) {
10711080
EnterDirectiveNest(TargetNest);
10721081
}
10731082

10741083
if (CurrentDirectiveIsNested()) {
10751084
if (llvm::omp::topTeamsSet.test(GetContextParent().directive)) {
10761085
HasInvalidTeamsNesting(beginDir.v, beginDir.source);
10771086
}
1078-
if ((llvm::omp::allTargetSet.test(GetContext().directive) ||
1079-
(GetContext().directive ==
1080-
llvm::omp::Directive::OMPD_target_data)) &&
1081-
(llvm::omp::allTargetSet.test(GetContextParent().directive) ||
1082-
(GetContextParent().directive ==
1083-
llvm::omp::Directive::OMPD_target_data))) {
1084-
context_.Warn(common::UsageWarning::OpenMPUsage,
1085-
parser::FindSourceLocation(x),
1086-
"If %s directive is nested inside %s region, the behaviour is unspecified"_port_en_US,
1087-
parser::ToUpperCaseLetters(
1088-
getDirectiveName(GetContext().directive).str()),
1089-
parser::ToUpperCaseLetters(
1090-
getDirectiveName(GetContextParent().directive).str()));
1091-
}
10921087
if (GetContext().directive == llvm::omp::Directive::OMPD_master) {
10931088
CheckMasterNesting(x);
10941089
}
@@ -1164,7 +1159,7 @@ void OmpStructureChecker::Leave(const parser::OpenMPBlockConstruct &) {
11641159
if (GetDirectiveNest(TargetBlockOnlyTeams)) {
11651160
ExitDirectiveNest(TargetBlockOnlyTeams);
11661161
}
1167-
if (GetContext().directive == llvm::omp::Directive::OMPD_target) {
1162+
if (llvm::omp::allTargetSet.test(GetContext().directive)) {
11681163
ExitDirectiveNest(TargetNest);
11691164
}
11701165
dirContext_.pop_back();

flang/test/Semantics/OpenMP/nested-simd.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ SUBROUTINE NESTED_BAD(N)
166166
end do
167167
!$omp end task
168168
!ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
169-
!ERROR: If TARGET directive is nested inside TARGET SIMD region, the behaviour is unspecified
170169
!$omp target
171170
do J = 1, N
172171
K = 2

flang/test/Semantics/OpenMP/nested-target.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ program main
5353
n1 = 10
5454
n2 = 10
5555
!$omp target teams map(to:a)
56-
!PORTABILITY: If TARGET DATA directive is nested inside TARGET TEAMS region, the behaviour is unspecified
56+
!PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified
5757
!$omp target data map(n1,n2)
5858
do i=1, n1
5959
do j=1, n2

0 commit comments

Comments
 (0)