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::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 &&