[flang-commits] [flang] [flang][openacc] Do not accept static and num for gang clause on routine dir (PR #77673)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Jan 10 11:39:40 PST 2024
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/77673
Only the dim argument is allowed on the gang clause for the routine directive. Reject static and num arguments in the semantic check.
>From 6da2c829d6222be3f6ce8eb5ac21f3a047f75810 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 10 Jan 2024 11:38:04 -0800
Subject: [PATCH] [flang][openacc] Do not accept static and num for gang clause
on routine dir
---
flang/lib/Semantics/check-acc-structure.cpp | 12 ++++++++++++
flang/test/Semantics/OpenACC/acc-routine.f90 | 10 ++++++++++
2 files changed, 22 insertions(+)
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
More information about the flang-commits
mailing list