[flang] ERROR STOP is not an image control statement
authorPeter Klausler <pklausler@nvidia.com>
Sun, 12 Jun 2022 17:16:46 +0000 (10:16 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Wed, 15 Jun 2022 21:39:31 +0000 (14:39 -0700)
The predicate that determines image control statements needs
to distinguish STOP (which is) from ERROR STOP (which isn't).

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

flang/lib/Semantics/tools.cpp

index 848bf2d..6701669 100644 (file)
@@ -875,11 +875,11 @@ std::optional<parser::Message> WhyNotModifiable(parser::CharBlock at,
 }
 
 class ImageControlStmtHelper {
-  using ImageControlStmts = std::variant<parser::ChangeTeamConstruct,
-      parser::CriticalConstruct, parser::EventPostStmt, parser::EventWaitStmt,
-      parser::FormTeamStmt, parser::LockStmt, parser::StopStmt,
-      parser::SyncAllStmt, parser::SyncImagesStmt, parser::SyncMemoryStmt,
-      parser::SyncTeamStmt, parser::UnlockStmt>;
+  using ImageControlStmts =
+      std::variant<parser::ChangeTeamConstruct, parser::CriticalConstruct,
+          parser::EventPostStmt, parser::EventWaitStmt, parser::FormTeamStmt,
+          parser::LockStmt, parser::SyncAllStmt, parser::SyncImagesStmt,
+          parser::SyncMemoryStmt, parser::SyncTeamStmt, parser::UnlockStmt>;
 
 public:
   template <typename T> bool operator()(const T &) {
@@ -929,6 +929,11 @@ public:
     }
     return false;
   }
+  bool operator()(const parser::StopStmt &stmt) {
+    // STOP is an image control statement; ERROR STOP is not
+    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);
   }