Skip to content

Commit 238b579

Browse files
authored
[flang][openacc] Do not accept static and num for gang clause on routine dir (llvm#77673)
Only the dim argument is allowed on the gang clause for the routine directive. Reject static and num arguments in the semantic check.
1 parent 8b61fc7 commit 238b579

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,28 @@ void AccStructureChecker::Enter(const parser::AccClause::Gang &g) {
592592
if (g.v) {
593593
bool hasNum = false;
594594
bool hasDim = false;
595+
bool hasStatic = false;
595596
const Fortran::parser::AccGangArgList &x = *g.v;
596597
for (const Fortran::parser::AccGangArg &gangArg : x.v) {
597598
if (std::get_if<Fortran::parser::AccGangArg::Num>(&gangArg.u)) {
598599
hasNum = true;
599600
} else if (std::get_if<Fortran::parser::AccGangArg::Dim>(&gangArg.u)) {
600601
hasDim = true;
602+
} else if (std::get_if<Fortran::parser::AccGangArg::Static>(&gangArg.u)) {
603+
hasStatic = true;
601604
}
602605
}
603606

607+
if (GetContext().directive == llvm::acc::Directive::ACCD_routine &&
608+
(hasStatic || hasNum)) {
609+
context_.Say(GetContext().clauseSource,
610+
"Only the dim argument is allowed on the %s clause on the %s directive"_err_en_US,
611+
parser::ToUpperCaseLetters(
612+
llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_gang)
613+
.str()),
614+
ContextDirectiveAsFortran());
615+
}
616+
604617
if (hasDim && hasNum) {
605618
context_.Say(GetContext().clauseSource,
606619
"The num argument is not allowed when dim is specified"_err_en_US);

flang/test/Semantics/OpenACC/acc-routine.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ subroutine sub3()
1414
!$acc routine bind(sub1)
1515
end subroutine
1616

17+
subroutine sub4()
18+
!ERROR: Only the dim argument is allowed on the GANG clause on the ROUTINE directive
19+
!$acc routine gang(num: 1)
20+
end subroutine
21+
22+
subroutine sub5()
23+
!ERROR: Only the dim argument is allowed on the GANG clause on the ROUTINE directive
24+
!$acc routine gang(static: 1)
25+
end subroutine
26+
1727
subroutine sub6()
1828
!ERROR: Clause GANG is not allowed if clause GANG appears on the ROUTINE directive
1929
!$acc routine gang gang

0 commit comments

Comments
 (0)