[llvm-branch-commits] [flang] 47567ca - [flang][openxx][NFC] Remove duplicated function to check required clauses

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 11 11:13:42 PST 2021


Author: Valentin Clement
Date: 2021-01-11T14:08:51-05:00
New Revision: 47567ca5faca147bcc28bcbbaa6bf448354bb5d4

URL: https://github.com/llvm/llvm-project/commit/47567ca5faca147bcc28bcbbaa6bf448354bb5d4
DIFF: https://github.com/llvm/llvm-project/commit/47567ca5faca147bcc28bcbbaa6bf448354bb5d4.diff

LOG: [flang][openxx][NFC] Remove duplicated function to check required clauses

Remove duplicated function to check for required clauses on a directive. This was
still there from the merging of OpenACC and OpenMP common semantic checks and it can now be
removed so we use only one function.

Reviewed By: sameeranjoshi

Differential Revision: https://reviews.llvm.org/D93575

Added: 
    

Modified: 
    flang/lib/Semantics/check-directive-structure.h
    flang/lib/Semantics/check-omp-structure.cpp
    flang/test/Semantics/omp-device-constructs.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index 822cdca9b66a..062f85b63b85 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -232,8 +232,6 @@ class DirectiveStructureChecker : public virtual BaseChecker {
   // Check that only clauses in set are after the specific clauses.
   void CheckOnlyAllowedAfter(C clause, common::EnumSet<C, ClauseEnumSize> set);
 
-  void CheckRequired(C clause);
-
   void CheckRequireAtLeastOneOf();
 
   void CheckAllowed(C clause);
@@ -326,6 +324,8 @@ DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::ClauseSetToString(
 template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
 void DirectiveStructureChecker<D, C, PC,
     ClauseEnumSize>::CheckRequireAtLeastOneOf() {
+  if (GetContext().requiredClauses.empty())
+    return;
   for (auto cl : GetContext().actualClauses) {
     if (GetContext().requiredClauses.test(cl))
       return;
@@ -447,17 +447,6 @@ void DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::SayNotMatching(
       .Attach(beginSource, "Does not match directive"_en_US);
 }
 
-// Check that at least one of the required clauses is present on the directive.
-template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
-void DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::CheckRequired(C c) {
-  if (!FindClause(c)) {
-    context_.Say(GetContext().directiveSource,
-        "At least one %s clause must appear on the %s directive"_err_en_US,
-        parser::ToUpperCaseLetters(getClauseName(c).str()),
-        ContextDirectiveAsFortran());
-  }
-}
-
 // Check the value of the clause is a positive parameter.
 template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
 void DirectiveStructureChecker<D, C, PC,

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 1a7e1dfdbfd2..4d1c96f66905 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -393,8 +393,7 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
         llvm::omp::Clause::OMPC_copyprivate, {llvm::omp::Clause::OMPC_nowait});
   }
 
-  GetContext().requiredClauses.IterateOverMembers(
-      [this](llvm::omp::Clause c) { CheckRequired(c); });
+  CheckRequireAtLeastOneOf();
 }
 
 void OmpStructureChecker::Enter(const parser::OmpClause &x) {

diff  --git a/flang/test/Semantics/omp-device-constructs.f90 b/flang/test/Semantics/omp-device-constructs.f90
index 8386744571d2..1d8c83e699dc 100644
--- a/flang/test/Semantics/omp-device-constructs.f90
+++ b/flang/test/Semantics/omp-device-constructs.f90
@@ -122,7 +122,7 @@ program main
   enddo
   !$omp end target data
 
-  !ERROR: At least one MAP clause must appear on the TARGET DATA directive
+  !ERROR: At least one of MAP clause must appear on the TARGET DATA directive
   !$omp target data device(0)
   do i = 1, N
      a = 3.14


        


More information about the llvm-branch-commits mailing list