[flang-commits] [flang] 238b579 - [flang][openacc] Do not accept static and num for gang clause on routine dir (#77673)

via flang-commits flang-commits at lists.llvm.org
Thu Jan 11 13:42:56 PST 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-01-11T13:42:52-08:00
New Revision: 238b5790ba2027a88706a320fe61bd21601b788b

URL: https://github.com/llvm/llvm-project/commit/238b5790ba2027a88706a320fe61bd21601b788b
DIFF: https://github.com/llvm/llvm-project/commit/238b5790ba2027a88706a320fe61bd21601b788b.diff

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

Only the dim argument is allowed on the gang clause for the routine
directive. Reject static and num arguments in the semantic check.

Added: 
    

Modified: 
    flang/lib/Semantics/check-acc-structure.cpp
    flang/test/Semantics/OpenACC/acc-routine.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index d69e1c597e2fbf..44aaa1fdd80364 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -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);

diff  --git a/flang/test/Semantics/OpenACC/acc-routine.f90 b/flang/test/Semantics/OpenACC/acc-routine.f90
index 42762f537b8bc7..8281822ca01d0c 100644
--- a/flang/test/Semantics/OpenACC/acc-routine.f90
+++ b/flang/test/Semantics/OpenACC/acc-routine.f90
@@ -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


        


More information about the flang-commits mailing list