When an environment variable NO_STOP_MESSAGE=1 is set,
assume that STOP statements with a successful code
have QUIET=.TRUE.
Differential Revision: https://reviews.llvm.org/
D113701
}
}
+ 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
}
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
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
+#include "environment.h"
#include "file.h"
#include "io-error.h"
#include "terminator.h"
[[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) {