Skip to content

Commit 0ba34fa

Browse files
Address review comments and compilation failure
1 parent d1075ea commit 0ba34fa

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ extractOmpDirective(const parser::OpenMPConstruct &ompConstruct) {
381381
[](const parser::OpenMPDeclarativeAllocate &c) {
382382
return llvm::omp::OMPD_allocate;
383383
},
384+
[](const parser::OpenMPDispatchConstruct &c) {
385+
return llvm::omp::OMPD_dispatch;
386+
},
384387
[](const parser::OpenMPExecutableAllocate &c) {
385388
return llvm::omp::OMPD_allocate;
386389
},

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,28 @@ void OmpStructureChecker::Enter(const parser::OmpErrorDirective &x) {
17501750

17511751
void OmpStructureChecker::Enter(const parser::OpenMPDispatchConstruct &x) {
17521752
PushContextAndClauseSets(x.source, llvm::omp::Directive::OMPD_dispatch);
1753+
const auto &block{std::get<parser::Block>(x.t)};
1754+
if (block.empty() || block.size() > 1) {
1755+
context_.Say(x.source,
1756+
"The DISPATCH construct is empty or contains more than one statement"_err_en_US);
1757+
return;
1758+
}
1759+
1760+
auto it{block.begin()};
1761+
bool passChecks{false};
1762+
if (const parser::AssignmentStmt *assignStmt{
1763+
parser::Unwrap<parser::AssignmentStmt>(*it)}) {
1764+
if (parser::Unwrap<parser::FunctionReference>(assignStmt->t)) {
1765+
passChecks = true;
1766+
}
1767+
} else if (parser::Unwrap<parser::CallStmt>(*it)) {
1768+
passChecks = true;
1769+
}
1770+
1771+
if (!passChecks) {
1772+
context_.Say(x.source,
1773+
"The DISPATCH construct does not contain a SUBROUTINE or FUNCTION"_err_en_US);
1774+
}
17531775
}
17541776

17551777
void OmpStructureChecker::Leave(const parser::OpenMPDispatchConstruct &x) {

flang/test/Lower/OpenMP/Todo/dispatch.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ program p
55
integer r
66
r = 1
77
!$omp dispatch nowait
8-
print *,r
8+
call foo()
9+
contains
10+
subroutine foo
11+
end subroutine
912
end program p
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
3+
subroutine sb1
4+
integer :: r
5+
r = 1
6+
!ERROR: The DISPATCH construct does not contain a SUBROUTINE or FUNCTION
7+
!$omp dispatch nowait
8+
print *,r
9+
end subroutine
10+
subroutine sb2
11+
integer :: r
12+
!ERROR: The DISPATCH construct is empty or contains more than one statement
13+
!$omp dispatch
14+
call foo()
15+
r = bar()
16+
!$omp end dispatch
17+
contains
18+
subroutine foo
19+
end subroutine foo
20+
function bar
21+
integer :: bar
22+
bar = 2
23+
end function
24+
end subroutine

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ def OMPC_Novariants : Clause<"novariants"> {
321321
}
322322
def OMPC_NoWait : Clause<"nowait"> {
323323
let clangClass = "OMPNowaitClause";
324-
let clangClass = "OmpNowaitClause";
325324
}
326325
def OMP_NUMTASKS_Strict : ClauseVal<"strict", 1, 1> {}
327326
def OMP_NUMTASKS_Unknown : ClauseVal<"unknown", 2, 0> { let isDefault = 1; }

0 commit comments

Comments
 (0)