[PATCH] D118509: [flang] Implement a runtime routine to report fatal errors with source position
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 28 15:48:47 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb933225f491: [flang] Implement a runtime routine to report fatal errors with source position (authored by PeteSteinfeld).
Changed prior to commit:
https://reviews.llvm.org/D118509?vs=404148&id=404187#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118509/new/
https://reviews.llvm.org/D118509
Files:
flang/include/flang/Runtime/stop.h
flang/runtime/stop.cpp
flang/unittests/Runtime/Stop.cpp
Index: flang/unittests/Runtime/Stop.cpp
===================================================================
--- flang/unittests/Runtime/Stop.cpp
+++ flang/unittests/Runtime/Stop.cpp
@@ -83,3 +83,14 @@
}
TEST(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); }
+
+TEST(TestProgramEnd, CrashTest) {
+ static const std::string crashMessage{"bad user code"};
+ static const std::string fileName{"file name"};
+ static const std::string headMessage{"fatal Fortran runtime error\\("};
+ static const std::string tailMessage{":343\\): "};
+ static const std::string fullMessage{
+ headMessage + fileName + tailMessage + crashMessage};
+ EXPECT_DEATH(RTNAME(Crash)(crashMessage.c_str(), fileName.c_str(), 343),
+ fullMessage.c_str());
+}
Index: flang/runtime/stop.cpp
===================================================================
--- flang/runtime/stop.cpp
+++ flang/runtime/stop.cpp
@@ -143,4 +143,9 @@
}
[[noreturn]] void RTNAME(Abort)() { std::abort(); }
+
+[[noreturn]] void RTNAME(Crash)(
+ const char *message, const char *source, int line) {
+ Fortran::runtime::Terminator{source, line}.Crash(message);
+}
}
Index: flang/include/flang/Runtime/stop.h
===================================================================
--- flang/include/flang/Runtime/stop.h
+++ flang/include/flang/Runtime/stop.h
@@ -30,6 +30,10 @@
NORETURN void RTNAME(Exit)(int status = EXIT_SUCCESS);
NORETURN void RTNAME(Abort)(NO_ARGUMENTS);
+// Crash with an error message when the program dynamically violates a Fortran
+// constraint.
+NORETURN void RTNAME(Crash)(const char *message, const char *source, int line);
+
FORTRAN_EXTERN_C_END
#endif // FORTRAN_RUNTIME_STOP_H_
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118509.404187.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/be83e27f/attachment.bin>
More information about the llvm-commits
mailing list