Skip to content

[flang][runtime] Accept '\n' as space in internal list-directed input #107716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

klausler
Copy link
Contributor

@klausler klausler commented Sep 7, 2024

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.

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.
@klausler klausler requested a review from vdonaldson September 7, 2024 20:17
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Sep 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/107716.diff

1 Files Affected:

  • (modified) flang/runtime/io-stmt.h (+3-2)
diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h
index d67d1ec80afcea..2e0ca46078ecdc 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;

@klausler klausler merged commit ea858e3 into llvm:main Sep 10, 2024
11 checks passed
@klausler klausler deleted the fs24283 branch September 10, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants