[flang-commits] [flang] fbb020f - [flang] Extension: allow tabs in output format strings

peter klausler via flang-commits flang-commits at lists.llvm.org
Fri Oct 22 15:56:04 PDT 2021


Author: peter klausler
Date: 2021-10-22T15:53:29-07:00
New Revision: fbb020fb48be454da35c77798dc63fd3304c0b80

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

LOG: [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

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 67a087d5daae..02276fbe45e5 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -122,6 +122,7 @@ end
   files are easier to write and use.
 * $ and \ edit descriptors are supported in FORMAT to suppress newline
   output on user prompts.
+* Tabs in format strings (not `FORMAT` statements) are allowed on output.
 * REAL and DOUBLE PRECISION variable and bounds in DO loops
 * Integer literals without explicit kind specifiers that are out of range
   for the default kind of INTEGER are assumed to have the least larger kind

diff  --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h
index b0ebcbc607fa..a32bb8e928fd 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang/runtime/format-implementation.h
@@ -359,6 +359,10 @@ int FormatControl<CONTEXT>::CueUpNextDataEdit(Context &context, bool stop) {
       context.AdvanceRecord(repeat && *repeat > 0 ? *repeat : 1);
     } else if (ch == '$' || ch == '\\') {
       context.mutableModes().nonAdvancing = true;
+    } else if (ch == '\t' || ch == '\v') {
+      // Tabs (extension)
+      // TODO: any other raw characters?
+      context.Emit(format_ + offset_ - 1, 1);
     } else {
       context.SignalError(IostatErrorInFormat,
           "Invalid character '%c' in FORMAT", static_cast<char>(ch));


        


More information about the flang-commits mailing list