[flang-commits] [flang] 1b56f27 - [flang] Detect image control statements in non-construct IF statements

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Mar 27 17:13:26 PDT 2023


Author: Peter Klausler
Date: 2023-03-27T17:13:20-07:00
New Revision: 1b56f273b27114322187ea0509762671cdec9e84

URL: https://github.com/llvm/llvm-project/commit/1b56f273b27114322187ea0509762671cdec9e84
DIFF: https://github.com/llvm/llvm-project/commit/1b56f273b27114322187ea0509762671cdec9e84.diff

LOG: [flang] Detect image control statements in non-construct IF statements

The utility routine in semantics that determines whether an
executable construct constitutes an image control statement
was not examining the single action statement controlled by
a non-construct IF statement, e.g. 'IF(P) STOP'.

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

Added: 
    

Modified: 
    flang/lib/Semantics/tools.cpp
    flang/test/Semantics/doconcurrent01.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 25a5c0e99131..2304812a4d05 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -848,6 +848,9 @@ class ImageControlStmtHelper {
   template <typename T> bool operator()(const common::Indirection<T> &x) {
     return (*this)(x.value());
   }
+  template <typename A> bool operator()(const parser::Statement<A> &x) {
+    return (*this)(x.statement);
+  }
   bool operator()(const parser::AllocateStmt &stmt) {
     const auto &allocationList{std::get<std::list<parser::Allocation>>(stmt.t)};
     for (const auto &allocation : allocationList) {
@@ -894,8 +897,13 @@ class ImageControlStmtHelper {
     return std::get<parser::StopStmt::Kind>(stmt.t) ==
         parser::StopStmt::Kind::Stop;
   }
-  bool operator()(const parser::Statement<parser::ActionStmt> &stmt) {
-    return common::visit(*this, stmt.statement.u);
+  bool operator()(const parser::IfStmt &stmt) {
+    return (*this)(
+        std::get<parser::UnlabeledStatement<parser::ActionStmt>>(stmt.t)
+            .statement);
+  }
+  bool operator()(const parser::ActionStmt &stmt) {
+    return common::visit(*this, stmt.u);
   }
 
 private:

diff  --git a/flang/test/Semantics/doconcurrent01.f90 b/flang/test/Semantics/doconcurrent01.f90
index 84297fbecc3e..c44c1e27528f 100644
--- a/flang/test/Semantics/doconcurrent01.f90
+++ b/flang/test/Semantics/doconcurrent01.f90
@@ -22,6 +22,11 @@ subroutine do_concurrent_test1(i,n)
      SYNC IMAGES (*)
 !ERROR: An image control statement is not allowed in DO CONCURRENT
      SYNC MEMORY
+!ERROR: An image control statement is not allowed in DO CONCURRENT
+     stop
+!ERROR: An image control statement is not allowed in DO CONCURRENT
+     if (.false.) stop
+     error stop ! ok
 !ERROR: RETURN is not allowed in DO CONCURRENT
      return
 10 continue


        


More information about the flang-commits mailing list