Skip to content

Commit fbb020f

Browse files
committed
[flang] Extension: allow tabs in output format strings
A CHARACTER variable used as an output format may contain unquoted tab characters, which are treated as if they had been quoted. This is an extension supported by all other Fortran compilers to which I have access. Differential Revision: https://reviews.llvm.org/D112350
1 parent ce71f8e commit fbb020f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

flang/docs/Extensions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ end
122122
files are easier to write and use.
123123
* $ and \ edit descriptors are supported in FORMAT to suppress newline
124124
output on user prompts.
125+
* Tabs in format strings (not `FORMAT` statements) are allowed on output.
125126
* REAL and DOUBLE PRECISION variable and bounds in DO loops
126127
* Integer literals without explicit kind specifiers that are out of range
127128
for the default kind of INTEGER are assumed to have the least larger kind

flang/runtime/format-implementation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ int FormatControl<CONTEXT>::CueUpNextDataEdit(Context &context, bool stop) {
359359
context.AdvanceRecord(repeat && *repeat > 0 ? *repeat : 1);
360360
} else if (ch == '$' || ch == '\\') {
361361
context.mutableModes().nonAdvancing = true;
362+
} else if (ch == '\t' || ch == '\v') {
363+
// Tabs (extension)
364+
// TODO: any other raw characters?
365+
context.Emit(format_ + offset_ - 1, 1);
362366
} else {
363367
context.SignalError(IostatErrorInFormat,
364368
"Invalid character '%c' in FORMAT", static_cast<char>(ch));

0 commit comments

Comments
 (0)