File tree Expand file tree Collapse file tree 5 files changed +53
-2
lines changed
llvm/include/llvm/Frontend/OpenMP Expand file tree Collapse file tree 5 files changed +53
-2
lines changed Original file line number Diff line number Diff 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 },
Original file line number Diff line number Diff line change @@ -1750,6 +1750,28 @@ void OmpStructureChecker::Enter(const parser::OmpErrorDirective &x) {
17501750
17511751void 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
17551777void OmpStructureChecker::Leave (const parser::OpenMPDispatchConstruct &x) {
Original file line number Diff line number Diff 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
912end program p
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -321,7 +321,6 @@ def OMPC_Novariants : Clause<"novariants"> {
321321}
322322def OMPC_NoWait : Clause<"nowait"> {
323323 let clangClass = "OMPNowaitClause";
324- let clangClass = "OmpNowaitClause";
325324}
326325def OMP_NUMTASKS_Strict : ClauseVal<"strict", 1, 1> {}
327326def OMP_NUMTASKS_Unknown : ClauseVal<"unknown", 2, 0> { let isDefault = 1; }
You can’t perform that action at this time.
0 commit comments