Skip to content
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

[Flang] Incorrect diagnostic on v_list in defined I/O #125878

Closed
DanielCChen opened this issue Feb 5, 2025 · 1 comment · Fixed by #125898
Closed

[Flang] Incorrect diagnostic on v_list in defined I/O #125878

DanielCChen opened this issue Feb 5, 2025 · 1 comment · Fixed by #125898
Assignees

Comments

@DanielCChen
Copy link
Contributor

Consider the following code

module m
    type base
        real(4), allocatable :: d1
    end type

    interface read(formatted)
        subroutine formattedRead (dtv, unit, iotype, v_list, iostat, iomsg)
        import base
            class (base), intent(inout) :: dtv
            integer, intent(in) :: unit
            character(*), intent(in) :: iotype
            integer, intent(in) :: v_list(2:)  !<-- this is legal
            integer, intent(out) :: iostat
            character(*), intent(inout) :: iomsg
        end subroutine
    end interface
end module

Flang currently issues an error as:

./t.f:12:36: error: Dummy argument 'v_list' of a defined input/output procedure must be deferred shape
              integer, intent(in) :: v_list(2:)  !<-- this is legal
                                     ^^^^^^
  1. The code is valid.
  2. The error message complains about "deferred shape" where the v_list is supposed to be "assumed-shape".

All ifort, gfortran and XLF compile the code successfully.

@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2025

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code ``` module m type base real(4), allocatable :: d1 end type
interface read(formatted)
    subroutine formattedRead (dtv, unit, iotype, v_list, iostat, iomsg)
    import base
        class (base), intent(inout) :: dtv
        integer, intent(in) :: unit
        character(*), intent(in) :: iotype
        integer, intent(in) :: v_list(2:)  !&lt;-- this is legal
        integer, intent(out) :: iostat
        character(*), intent(inout) :: iomsg
    end subroutine
end interface

end module


Flang currently issues an error as:

./t.f:12:36: error: Dummy argument 'v_list' of a defined input/output procedure must be deferred shape
integer, intent(in) :: v_list(2:) !<-- this is legal
^^^^^^


1. The code is valid.
2. The error message complains about "deferred shape" where the `v_list` is supposed to be "assumed-shape". 

All ifort, gfortran and XLF compile the code successfully.
</details>

@klausler klausler self-assigned this Feb 5, 2025
klausler added a commit to klausler/llvm-project that referenced this issue Feb 5, 2025
The check that "v_list" be deferred shape is just wrong;
there are no deferred shape non-pointer non-allocatable dummy
arguments in Fortran.  Correct to check for an assumed shape
dummy argument.  And de-split the error messages that were split
across multiple source lines, making them much harder to find
with grep.

Fixes llvm#125878.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this issue Feb 27, 2025
The check that "v_list" be deferred shape is just wrong; there are no
deferred shape non-pointer non-allocatable dummy arguments in Fortran.
Correct to check for an assumed shape dummy argument. And de-split the
error messages that were split across multiple source lines, making them
much harder to find with grep.

Fixes llvm/llvm-project#125878.
cheezeburglar pushed a commit to cheezeburglar/llvm-project that referenced this issue Feb 28, 2025
The check that "v_list" be deferred shape is just wrong; there are no
deferred shape non-pointer non-allocatable dummy arguments in Fortran.
Correct to check for an assumed shape dummy argument. And de-split the
error messages that were split across multiple source lines, making them
much harder to find with grep.

Fixes llvm#125878.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants