diff options
author | Peter Klausler <pklausler@nvidia.com> | 2022-04-29 02:30:46 +0300 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2022-05-09 23:00:15 +0300 |
commit | 28b5e99a4c84f687b4c43c46a293e9f4b4cf6986 (patch) | |
tree | b1e31567cbf59a1488745d0ae4187b3ed37bdfe6 /flang | |
parent | fb9ec95cf0c2ed6e3b5273b2274eac70dd8bd3d4 (diff) |
[flang][runtime] (G0) for CHARACTER means (A), not (A0)
I'm emitting zero characters for (G0) formatting of CHARACTER values
instead of using their lengths to determine the output field width.
Differential Revision: https://reviews.llvm.org/D125056
Diffstat (limited to 'flang')
-rw-r--r-- | flang/runtime/edit-output.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp index 842ee837d69e..eca27e3e2c0c 100644 --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -627,9 +627,15 @@ bool ListDirectedCharacterOutput(IoStatementState &io, template <typename CHAR> bool EditCharacterOutput(IoStatementState &io, const DataEdit &edit, const CHAR *x, std::size_t length) { + int len{static_cast<int>(length)}; + int width{edit.width.value_or(len)}; switch (edit.descriptor) { case 'A': + break; case 'G': + if (width == 0) { + width = len; + } break; case 'B': return EditBOZOutput<1>(io, edit, @@ -646,8 +652,6 @@ bool EditCharacterOutput(IoStatementState &io, const DataEdit &edit, edit.descriptor); return false; } - int len{static_cast<int>(length)}; - int width{edit.width.value_or(len)}; return io.EmitRepeated(' ', std::max(0, width - len)) && io.EmitEncoded(x, std::min(width, len)); } |