[flang-commits] [flang] [llvm] [flang] [flang-rt] Implement AT edit descriptor for Fortran 202X with appropriate handling and tests (PR #189157)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Fri Apr 10 12:52:18 PDT 2026


================
@@ -1018,3 +1018,66 @@ TEST(IOApiTests, ConfusingMinimization) {
   EXPECT_TRUE(CompareFormattedStrings(" 65504. ", got))
       << "expected ' 65504. ', got '" << got << '\''; // not 65500.!
 }
+
+// Test AT edit descriptor (F2023) - trims trailing blanks on output
+TEST(IOApiTests, ATEditDescriptorOutput) {
+  // Helper to test AT formatted output
+  auto testAT = [](const char *format, const char *input, std::size_t inputLen,
+                    const char *expect) {
+    char buffer[800];
+    auto cookie{IONAME(BeginInternalFormattedOutput)(
+        buffer, sizeof buffer, format, std::strlen(format))};
+    EXPECT_TRUE(IONAME(OutputAscii)(cookie, input, inputLen));
+    auto status{IONAME(EndIoStatement)(cookie)};
+    EXPECT_EQ(status, 0) << "AT test: '" << format << "' failed, status "
+                         << static_cast<int>(status);
+    std::string got{buffer, sizeof buffer};
+    auto lastNonBlank{got.find_last_not_of(" ")};
+    if (lastNonBlank != std::string::npos) {
+      got.resize(lastNonBlank + 1);
+    }
----------------
eugeneepshteyn wrote:

This trims, so `"hello     "` becomes `"hello"`. Wouldn't that mean that if `"(AT)"` is replaced with `"(A)"`, the test would still pass?

https://github.com/llvm/llvm-project/pull/189157


More information about the flang-commits mailing list