[flang-commits] [flang] [flang] Fix execute_command_line cmdstat is not set when error occurs (PR #93023)
via flang-commits
flang-commits at lists.llvm.org
Thu May 30 11:34:30 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f68548135b8f9a02beac842646ab89bcaad9d400 5e51e64c591940b44a79fe0720b8d62889f61405 -- flang/runtime/execute.cpp flang/unittests/Runtime/CommandTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp
index cb93da6336..3dd1355077 100644
--- a/flang/runtime/execute.cpp
+++ b/flang/runtime/execute.cpp
@@ -62,7 +62,7 @@ void CheckAndStoreIntToDescriptor(
// If a condition occurs that would assign a nonzero value to CMDSTAT but
// the CMDSTAT variable is not present, error termination is initiated.
-std::int64_t TerminationCheck(std::int64_t status, const Descriptor *cmdstat,
+std::int64_t TerminationCheck(std::int64_t status, const Descriptor *cmdstat,
const Descriptor *cmdmsg, Terminator &terminator) {
#ifdef _WIN32
// On WIN32 API std::system returns exit status directly
@@ -164,7 +164,8 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
if (wait) {
// either wait is not specified or wait is true: synchronous mode
std::int64_t status{std::system(newCmd)};
- std::int64_t exitStatusVal{TerminationCheck(status, cmdstat, cmdmsg, terminator)};
+ std::int64_t exitStatusVal{
+ TerminationCheck(status, cmdstat, cmdmsg, terminator)};
// If sync, assigned processor-dependent exit status. Otherwise unchanged
CheckAndStoreIntToDescriptor(exitstat, exitStatusVal, terminator);
} else {
diff --git a/flang/unittests/Runtime/CommandTest.cpp b/flang/unittests/Runtime/CommandTest.cpp
index 38060a5ba3..27dce144b8 100644
--- a/flang/unittests/Runtime/CommandTest.cpp
+++ b/flang/unittests/Runtime/CommandTest.cpp
@@ -379,18 +379,19 @@ TEST_F(ZeroArguments, ECLNotExecutedCommandErrorSync) {
CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 3);
// removing the file should have no error on Linux, have error on Windows
- OwningPtr<Descriptor> commandClean{CharDescriptor("rm -f NotExecutedCommandFile")};
+ OwningPtr<Descriptor> commandClean{
+ CharDescriptor("rm -f NotExecutedCommandFile")};
OwningPtr<Descriptor> cmdMsgNoErr{CharDescriptor("No Error")};
RTNAME(ExecuteCommandLine)
(*commandClean.get(), wait, exitStat.get(), cmdStat.get(), cmdMsgNoErr.get());
#ifdef _WIN32
CheckDescriptorEqInt<std::int64_t>(exitStat.get(), 1);
CheckDescriptorEqStr(cmdMsgNoErr.get(), "Invalid ");
- CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 3);
+ CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 3);
#else
CheckDescriptorEqInt<std::int64_t>(exitStat.get(), 0);
CheckDescriptorEqStr(cmdMsgNoErr.get(), "No Error");
- CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 0);
+ CheckDescriptorEqInt<std::int64_t>(cmdStat.get(), 0);
#endif
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/93023
More information about the flang-commits
mailing list