[flang-commits] [flang] 44ff4df - [flang] Extension: don't require commas between most edit descriptors in formats

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Mar 1 15:16:06 PST 2022


Author: Peter Klausler
Date: 2022-03-01T15:15:59-08:00
New Revision: 44ff4df6debf5a8d8fd1478ed6da0e374e669a8d

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

LOG: [flang] Extension: don't require commas between most edit descriptors in formats

The standard explicitly allows a comma to be omitted between a 'P'
edit descriptor and a following numeric edit descriptor (e.g., 1PE10.1),
and before and after a '/' edit descriptor, but otherwise requires them
between edit descriptors.  Most implementations, however, only require
commas where they prevent ambiguity, and accept things like 1XI10.
This extension is already assumed by the static FORMAT checker in
semantics.  Patch the runtime to behave accordingly.

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

Added: 
    

Modified: 
    flang/docs/Extensions.md
    flang/runtime/format-implementation.h

Removed: 
    


################################################################################
diff  --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 4953186c71127..4a038742ddb3f 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -217,6 +217,8 @@ end
 * At runtime, `NAMELIST` input will skip over `NAMELIST` groups
   with other names, and will treat text before and between groups
   as if they were comment lines, even if not begun with `!`.
+* Commas are required in FORMAT statements and character variables
+  only when they prevent ambiguity.
 
 ### Extensions supported when enabled by options
 

diff  --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h
index 6b1a64b96a851..11f3ad7d18e44 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang/runtime/format-implementation.h
@@ -301,8 +301,14 @@ int FormatControl<CONTEXT>::CueUpNextDataEdit(Context &context, bool stop) {
       if (ch != 'P') { // 1PE5.2 - comma not required (C1302)
         CharType peek{Capitalize(PeekNext())};
         if (peek >= 'A' && peek <= 'Z') {
-          next = peek;
-          ++offset_;
+          if (ch == 'A' /* anticipate F'202X AT editing */ || ch == 'B' ||
+              ch == 'D' || ch == 'E' || ch == 'R' || ch == 'S' || ch == 'T') {
+            // Assume a two-letter edit descriptor
+            next = peek;
+            ++offset_;
+          } else {
+            // extension: assume a comma between 'ch' and 'peek'
+          }
         }
       }
       if ((!next &&


        


More information about the flang-commits mailing list