Skip to content

[flang][openacc] Do not accept static and num for gang clause on routine dir #77673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions flang/lib/Semantics/check-acc-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,28 @@ 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);
Expand Down
10 changes: 10 additions & 0 deletions flang/test/Semantics/OpenACC/acc-routine.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ 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

subroutine sub6()
!ERROR: Clause GANG is not allowed if clause GANG appears on the ROUTINE directive
!$acc routine gang gang
Expand Down