[flang-commits] [flang] [flang] Keep a LOGICAL input item unchanged on big-endian targets (PR #228588)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Oct 5 10:53:30 PDT 2026
eugeneepshteyn wrote:
One more:
(This comment was generated with the help of AI)
The fix relies on `InputLogical` not storing to its `bool&` for a null value, and nothing tests that. `InputExtensions.cpp` covers explicit values only, and `ListInputTest.cpp` covers null values for INTEGER only. Could you add a small runtime test, here or in a follow-up, e.g. in `flang-rt/unittests/Runtime/ListInputTest.cpp`:
```cpp
// Null values (F2023 13.10.3.2) leave a LOGICAL input item unchanged; lowering
// relies on InputLogical not storing to its bool& for them.
TEST(InputTest, TestListInputLogicalNullValues) {
constexpr int maxBufferLength{32};
char buffer[maxBufferLength];
SetCharacter(buffer, maxBufferLength, ",T,,,");
auto *cookie{IONAME(BeginInternalListInput)(buffer, maxBufferLength)};
bool actual[4]{true, false, true, false};
const bool expected[4]{true, true, true, false};
for (int j{0}; j < 4; ++j) {
IONAME(InputLogical)(cookie, actual[j]);
}
ASSERT_EQ(IONAME(EndIoStatement)(cookie), IostatOk);
for (int j{0}; j < 4; ++j) {
ASSERT_EQ(actual[j], expected[j]) << "item " << j;
}
}
```
Also, in the description, "on little-endian targets the result does not change" holds for canonical values only. A nonzero LOGICAL whose low byte is zero (e.g. `transfer(256, l)`) also lost its value on little-endian before this change, and keeps it now.
https://github.com/llvm/llvm-project/pull/228588
More information about the flang-commits
mailing list