From a5afb5404be21be36e90f44dcc9225dd8d9eb315 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Sat, 7 Sep 2024 13:14:52 -0700 Subject: [PATCH] [flang][runtime] Accept '\n' as space in internal list-directed input When scanning ahead for the first character in the next input item in list-directed internal input, allow a newline character to appear and treat it as a space, matching the behavior of nearly all other Fortran compilers. --- flang/runtime/io-stmt.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h index d67d1ec80afce..2e0ca46078ecd 100644 --- a/flang/runtime/io-stmt.h +++ b/flang/runtime/io-stmt.h @@ -194,8 +194,9 @@ class IoStatementState { std::size_t &byteCount) { auto ch{GetCurrentChar(byteCount)}; bool inNamelist{mutableModes().inNamelist}; - while (!ch || *ch == ' ' || *ch == '\t' || (inNamelist && *ch == '!')) { - if (ch && (*ch == ' ' || *ch == '\t')) { + while (!ch || *ch == ' ' || *ch == '\t' || *ch == '\n' || + (inNamelist && *ch == '!')) { + if (ch && (*ch == ' ' || *ch == '\t' || *ch == '\n')) { HandleRelativePosition(byteCount); } else if (!AdvanceRecord()) { return Fortran::common::nullopt;