[flang-commits] [flang] [flang][openacc] Do not accept static and num for gang clause on routine dir (PR #77673)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 10 11:40:09 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
Only the dim argument is allowed on the gang clause for the routine directive. Reject static and num arguments in the semantic check.
---
Full diff: https://github.com/llvm/llvm-project/pull/77673.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-acc-structure.cpp (+12)
- (modified) flang/test/Semantics/OpenACC/acc-routine.f90 (+10)
``````````diff
diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index 4a5798a8a531a4..5c2a871c322e3a 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -560,14 +560,26 @@ void AccStructureChecker::Enter(const parser::AccClause::Gang &g) {
if (g.v) {
bool hasNum = false;
bool hasDim = false;
+ bool hasStatic = false;
const Fortran::parser::AccGangArgList &x = *g.v;
for (const Fortran::parser::AccGangArg &gangArg : x.v) {
if (std::get_if<Fortran::parser::AccGangArg::Num>(&gangArg.u))
hasNum = true;
else if (std::get_if<Fortran::parser::AccGangArg::Dim>(&gangArg.u))
hasDim = true;
+ else if (std::get_if<Fortran::parser::AccGangArg::Static>(&gangArg.u))
+ hasStatic = true;
}
+ if (GetContext().directive == llvm::acc::Directive::ACCD_routine &&
+ (hasStatic || hasNum))
+ context_.Say(GetContext().clauseSource,
+ "Only the dim argument is allowed on the %s clause on the %s directive"_err_en_US,
+ parser::ToUpperCaseLetters(
+ llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_gang)
+ .str()),
+ ContextDirectiveAsFortran());
+
if (hasDim && hasNum)
context_.Say(GetContext().clauseSource,
"The num argument is not allowed when dim is specified"_err_en_US);
diff --git a/flang/test/Semantics/OpenACC/acc-routine.f90 b/flang/test/Semantics/OpenACC/acc-routine.f90
index 4dcb849c642c83..f27084115fbee2 100644
--- a/flang/test/Semantics/OpenACC/acc-routine.f90
+++ b/flang/test/Semantics/OpenACC/acc-routine.f90
@@ -13,3 +13,13 @@ subroutine sub2(a)
subroutine sub3()
!$acc routine bind(sub1)
end subroutine
+
+subroutine sub4()
+ !ERROR: Only the dim argument is allowed on the GANG clause on the ROUTINE directive
+ !$acc routine gang(num: 1)
+end subroutine
+
+subroutine sub5()
+ !ERROR: Only the dim argument is allowed on the GANG clause on the ROUTINE directive
+ !$acc routine gang(static: 1)
+end subroutine
``````````
</details>
https://github.com/llvm/llvm-project/pull/77673
More information about the flang-commits
mailing list