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

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 17:00:48 PDT 2020


klausler created this revision.
klausler added reviewers: sscalpone, schweitz.
klausler added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84369

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


Index: flang/unittests/Runtime/hello.cpp
===================================================================
--- flang/unittests/Runtime/hello.cpp
+++ flang/unittests/Runtime/hello.cpp
@@ -138,6 +138,7 @@
       {"(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;"},
@@ -158,6 +159,7 @@
       {"(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;"},
Index: flang/runtime/format-implementation.h
===================================================================
--- flang/runtime/format-implementation.h
+++ flang/runtime/format-implementation.h
@@ -330,11 +330,13 @@
       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 &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84369.279972.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200723/6fd14e34/attachment-0001.bin>


More information about the flang-commits mailing list