[flang-commits] [flang] e574641 - [flang] Allow omission of comma in FORMAT(1PE5.2) in runtime

peter klausler via flang-commits flang-commits at lists.llvm.org
Mon Jul 27 15:03:43 PDT 2020


Author: peter klausler
Date: 2020-07-27T15:02:54-07:00
New Revision: e57464151d4c4912a7ec4d6fd0920056b2f75c7c

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

LOG: [flang] Allow omission of comma in FORMAT(1PE5.2) in runtime

A comma is not required between a scale factor and a following
data edit descriptor (C1302).

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D84369

Added: 
    

Modified: 
    flang/runtime/format-implementation.h
    flang/unittests/Runtime/hello.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h
index a4453cd172ea..ad8bbcbcdcbd 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang/runtime/format-implementation.h
@@ -330,11 +330,13 @@ int FormatControl<CONTEXT>::CueUpNextDataEdit(Context &context, bool stop) {
       offset_ += *repeat;
     } else if (ch >= 'A' && ch <= 'Z') {
       int start{offset_ - 1};
-      CharType next{Capitalize(PeekNext())};
-      if (next >= 'A' && next <= 'Z') {
-        ++offset_;
-      } else {
-        next = '\0';
+      CharType next{'\0'};
+      if (ch != 'P') { // 1PE5.2 - comma not required (C1302)
+        CharType peek{Capitalize(PeekNext())};
+        if (peek >= 'A' && peek <= 'Z') {
+          next = peek;
+          ++offset_;
+        }
       }
       if (ch == 'E' ||
           (!next &&

diff  --git a/flang/unittests/Runtime/hello.cpp b/flang/unittests/Runtime/hello.cpp
index f6db4a8e47dc..c38aedf4f654 100644
--- a/flang/unittests/Runtime/hello.cpp
+++ b/flang/unittests/Runtime/hello.cpp
@@ -175,6 +175,7 @@ int main() {
       {"(E32.17E0,';')", "          0.00000000000000000E+0;"},
       {"(G32.17E0,';')", "          0.0000000000000000    ;"},
       {"(1P,E32.17,';')", "         0.00000000000000000E+00;"},
+      {"(1PE32.17,';')", "         0.00000000000000000E+00;"}, // no comma
       {"(1P,F32.17,';')", "             0.00000000000000000;"},
       {"(1P,G32.17,';')", "          0.0000000000000000    ;"},
       {"(2P,E32.17,';')", "         00.0000000000000000E+00;"},
@@ -195,6 +196,7 @@ int main() {
       {"(E32.17E4,';')", "       0.10000000000000000E+0001;"},
       {"(G32.17E4,';')", "        1.0000000000000000      ;"},
       {"(1P,E32.17,';')", "         1.00000000000000000E+00;"},
+      {"(1PE32.17,';')", "         1.00000000000000000E+00;"}, // no comma
       {"(1P,F32.17,';')", "             0.10000000000000000;"},
       {"(1P,G32.17,';')", "          1.0000000000000000    ;"},
       {"(ES32.17,';')", "         1.00000000000000000E+00;"},


        


More information about the flang-commits mailing list