Skip to content

Conversation

@klausler
Copy link
Contributor

List-directed input statements maintain two flags ("eatComma_" and "hitSlash_") in their state that allow GetNextDataEdit() to detect and handle field separators (usually ',') and slashes in the input stream. For list-directed input in a defined input subroutine, it's necessary to copy those flags from the parent list-directed input statement (if any) and update them afterwards.

Fixes #154791.

@DanielCChen
Copy link
Contributor

DanielCChen commented Aug 28, 2025

The reducer in the issue still fails.
I updated the description of the issue with the expected output.

@llvmbot llvmbot added the flang Flang issues not falling into any other category label Aug 28, 2025
@klausler
Copy link
Contributor Author

I've added documentation to flang/docs/Extensions.md to describe how null values in list-directed input are interpreted here (13.10.3.2p2). It's the plain reading of "A null value has no effect on the definition status of the next effective item." and the portable interpretation across the most commonly-used compilers.

@DanielCChen
Copy link
Contributor

The reducer in the issue still fails. I updated the description of the issue with the expected output.

To clarify,
The output from the 1st read statement is still incorrect after this patch.
Flang still produces 1 3 4 where the expected output is 1 -1 3

When a "null" list-directed input field is encountered for a
corresponding effective input item, leave it unmodified even
if it has a derived type with a READ(FORMATTED) defined input
subroutine.

Fixes llvm#154791, although
not with the result that was intended.
@klausler
Copy link
Contributor Author

New commit header comment:

[flang][runtime] Handle null list-directed fields in child input

When a "null" list-directed input field is encountered for a                                                                                                    
corresponding effective input item, leave it unmodified even
if it has a derived type with a READ(FORMATTED) defined input
subroutine.
                                                                                                                                                                
Fixes https://github.com/llvm/llvm-project/issues/154791, although
not with the result that was intended.

Copy link
Contributor

@akuhlens akuhlens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this implementation coincides with how I interpret the standard. If most compilers also implement this interpretation then maximizing portability is important.

@klausler klausler merged commit 9005ae5 into llvm:main Aug 29, 2025
10 checks passed
@klausler klausler deleted the bug154791 branch August 29, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flang] Reading NULL input field failure

5 participants