[PATCH] D90280: [flang][openacc] Enforce no modifier on enter data and exit data clauses

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 18:51:48 PDT 2020


clementval created this revision.
clementval added reviewers: kiranchandramohan, kiranktp, SouraVX, jdoerfert, sameeranjoshi.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
clementval requested review of this revision.

Enter data can have the copyin clause and exit data can have the copyout clause.
Both clauses support modifier with other directive but for these two directives no modifier
are supported. This semantic check enforce this rule.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90280

Files:
  flang/lib/Semantics/check-acc-structure.cpp
  flang/lib/Semantics/check-acc-structure.h
  flang/test/Semantics/acc-clause-validity.f90


Index: flang/test/Semantics/acc-clause-validity.f90
===================================================================
--- flang/test/Semantics/acc-clause-validity.f90
+++ flang/test/Semantics/acc-clause-validity.f90
@@ -45,9 +45,12 @@
   !ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive
   !$acc enter data
 
-  !ERROR: Only the READONLY modifier is allowed for the COPYIN clause on the ENTER DATA directive
+  !ERROR: Modifier is not allowed on for the COPYIN clause on the ENTER DATA directive
   !$acc enter data copyin(zero: i)
 
+  !ERROR: Modifier is not allowed on for the COPYOUT clause on the EXIT DATA directive
+  !$acc exit data copyout(zero: i)
+
   !ERROR: Only the ZERO modifier is allowed for the CREATE clause on the ENTER DATA directive
   !$acc enter data create(readonly: i)
 
Index: flang/lib/Semantics/check-acc-structure.h
===================================================================
--- flang/lib/Semantics/check-acc-structure.h
+++ flang/lib/Semantics/check-acc-structure.h
@@ -115,6 +115,8 @@
       const llvm::acc::Directive directive,
       const parser::CharBlock &directiveSource) const;
 
+  bool CheckAllowedModifier(llvm::acc::Clause clause);
+
   llvm::StringRef getClauseName(llvm::acc::Clause clause) override;
   llvm::StringRef getDirectiveName(llvm::acc::Directive directive) override;
 };
Index: flang/lib/Semantics/check-acc-structure.cpp
===================================================================
--- flang/lib/Semantics/check-acc-structure.cpp
+++ flang/lib/Semantics/check-acc-structure.cpp
@@ -121,6 +121,19 @@
   llvm::acc::Directive currentDirective_;
 };
 
+bool AccStructureChecker::CheckAllowedModifier(llvm::acc::Clause clause) {
+  if (GetContext().directive == llvm::acc::ACCD_enter_data ||
+      GetContext().directive == llvm::acc::ACCD_exit_data) {
+    context_.Say(GetContext().clauseSource,
+        "Modifier is not allowed on for the %s clause "
+        "on the %s directive"_err_en_US,
+        parser::ToUpperCaseLetters(getClauseName(clause).str()),
+        ContextDirectiveAsFortran());
+    return true;
+  }
+  return false;
+}
+
 void AccStructureChecker::Enter(const parser::AccClause &x) {
   SetContextClause(x);
 }
@@ -375,6 +388,8 @@
   const auto &modifierClause{c.v};
   if (const auto &modifier{
           std::get<std::optional<parser::AccDataModifier>>(modifierClause.t)}) {
+    if (CheckAllowedModifier(llvm::acc::Clause::ACCC_copyin))
+      return;
     if (modifier->v != parser::AccDataModifier::Modifier::ReadOnly) {
       context_.Say(GetContext().clauseSource,
           "Only the READONLY modifier is allowed for the %s clause "
@@ -392,6 +407,8 @@
   const auto &modifierClause{c.v};
   if (const auto &modifier{
           std::get<std::optional<parser::AccDataModifier>>(modifierClause.t)}) {
+    if (CheckAllowedModifier(llvm::acc::Clause::ACCC_copyout))
+      return;
     if (modifier->v != parser::AccDataModifier::Modifier::Zero) {
       context_.Say(GetContext().clauseSource,
           "Only the ZERO modifier is allowed for the %s clause "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90280.301162.patch
Type: text/x-patch
Size: 3114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201028/1ae1dfc4/attachment.bin>


More information about the llvm-commits mailing list