[flang-commits] [flang] 41f36ee - [flang] Don't unparse 1X or X format as X (#183196)

via flang-commits flang-commits at lists.llvm.org
Thu Feb 26 07:10:07 PST 2026


Author: Peter Klausler
Date: 2026-02-26T07:10:02-08:00
New Revision: 41f36ee62d6e5ecbbf1696a3c255133e772e7b17

URL: https://github.com/llvm/llvm-project/commit/41f36ee62d6e5ecbbf1696a3c255133e772e7b17
DIFF: https://github.com/llvm/llvm-project/commit/41f36ee62d6e5ecbbf1696a3c255133e772e7b17.diff

LOG: [flang] Don't unparse 1X or X format as X (#183196)

The unparsing code emits a bare X control edit descriptor when its
repetition count is 1, since a bare X control edit descriptor defaults
to 1X. But it's not conforming usage, so it might cause a warning if
unparsed code is recompiled with -pedantic. So don't do that.

Added: 
    flang/test/Parser/bug2280.f90

Modified: 
    flang/lib/Parser/unparse.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 3d8ea9f703b2f..9d01bb74d70d3 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -1514,9 +1514,7 @@ class UnparseVisitor {
       Walk(x.count);
       break;
     case format::ControlEditDesc::Kind::X:
-      if (x.count != 1) {
-        Walk(x.count);
-      }
+      Walk(x.count);
       Word("X");
       break;
     case format::ControlEditDesc::Kind::Slash:

diff  --git a/flang/test/Parser/bug2280.f90 b/flang/test/Parser/bug2280.f90
new file mode 100644
index 0000000000000..d24b26ddeb0d8
--- /dev/null
+++ b/flang/test/Parser/bug2280.f90
@@ -0,0 +1,6 @@
+!RUN: %flang -fc1 -fdebug-unparse %s | FileCheck %s
+!CHECK: 1 FORMAT(1X)
+1 format(1x)
+!CHECK: 2 FORMAT(1X)
+2 format(x)
+end


        


More information about the flang-commits mailing list