Skip to content

Commit ea858e3

Browse files
authored
[flang][runtime] Accept '\n' as space in internal list-directed input (#107716)
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.
1 parent cd92c42 commit ea858e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

flang/runtime/io-stmt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ class IoStatementState {
194194
std::size_t &byteCount) {
195195
auto ch{GetCurrentChar(byteCount)};
196196
bool inNamelist{mutableModes().inNamelist};
197-
while (!ch || *ch == ' ' || *ch == '\t' || (inNamelist && *ch == '!')) {
198-
if (ch && (*ch == ' ' || *ch == '\t')) {
197+
while (!ch || *ch == ' ' || *ch == '\t' || *ch == '\n' ||
198+
(inNamelist && *ch == '!')) {
199+
if (ch && (*ch == ' ' || *ch == '\t' || *ch == '\n')) {
199200
HandleRelativePosition(byteCount);
200201
} else if (!AdvanceRecord()) {
201202
return Fortran::common::nullopt;

0 commit comments

Comments
 (0)