[PATCH] D113701: [flang] Respect NO_STOP_MESSAGE=1 in runtime

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 10:50:46 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a0af824ee22: [flang] Respect NO_STOP_MESSAGE=1 in runtime (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113701/new/

https://reviews.llvm.org/D113701

Files:
  flang/runtime/environment.cpp
  flang/runtime/environment.h
  flang/runtime/stop.cpp


Index: flang/runtime/stop.cpp
===================================================================
--- flang/runtime/stop.cpp
+++ flang/runtime/stop.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Runtime/stop.h"
+#include "environment.h"
 #include "file.h"
 #include "io-error.h"
 #include "terminator.h"
@@ -52,6 +53,9 @@
 [[noreturn]] void RTNAME(StopStatement)(
     int code, bool isErrorStop, bool quiet) {
   CloseAllExternalUnits("STOP statement");
+  if (Fortran::runtime::executionEnvironment.noStopMessage && code == 0) {
+    quiet = true;
+  }
   if (!quiet) {
     std::fprintf(stderr, "Fortran %s", isErrorStop ? "ERROR STOP" : "STOP");
     if (code != EXIT_SUCCESS) {
Index: flang/runtime/environment.h
===================================================================
--- flang/runtime/environment.h
+++ flang/runtime/environment.h
@@ -37,9 +37,11 @@
   int argc;
   const char **argv;
   const char **envp;
-  int listDirectedOutputLineLengthLimit;
+
+  int listDirectedOutputLineLengthLimit; // FORT_FMT_RECL
   enum decimal::FortranRounding defaultOutputRoundingMode;
-  Convert conversion;
+  Convert conversion; // FORT_CONVERT
+  bool noStopMessage; // NO_STOP_MESSAGE=1 inhibits "Fortran STOP"
 };
 extern ExecutionEnvironment executionEnvironment;
 } // namespace Fortran::runtime
Index: flang/runtime/environment.cpp
===================================================================
--- flang/runtime/environment.cpp
+++ flang/runtime/environment.cpp
@@ -67,6 +67,17 @@
     }
   }
 
+  if (auto *x{std::getenv("NO_STOP_MESSAGE")}) {
+    char *end;
+    auto n{std::strtol(x, &end, 10)};
+    if (n >= 0 && n <= 1 && *end == '\0') {
+      noStopMessage = n != 0;
+    } else {
+      std::fprintf(stderr,
+          "Fortran runtime: NO_STOP_MESSAGE=%s is invalid; ignored\n", x);
+    }
+  }
+
   // TODO: Set RP/ROUND='PROCESSOR_DEFINED' from environment
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113701.386892.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211112/b2edc420/attachment.bin>


More information about the llvm-commits mailing list