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] Missing compile-time diagnostic on different declare type of SOURCE and PAD argument of intrinsic RESHAPE #124976

Closed
DanielCChen opened this issue Jan 29, 2025 · 1 comment · Fixed by #125133
Assignees

Comments

@DanielCChen
Copy link
Contributor

Consider the following code:

program main
    type Base
        integer   :: i = 88
    end type

    type, extends(Base) :: Child
        integer :: j = 99
    end type

    type(Child) :: c1(10)
    type(Child) :: c2(3,5)
    class(Base), allocatable :: b1(:)

    c1 = (/ (Child(i,i+100), i=1,10) /)
    allocate(Child::b1(2))

    c2 = reshape(c1, (/3,5/), b1, (/2,1/))
end

Flang is issue an error as

error: loc("t.f":17:5): 'hlfir.reshape' op ARRAY and PAD must be of the same type
error: verification of lowering to FIR failed

While the complain is correct as the standard requires SOURCE and PAD to have the same declare and dynamic type, it should be a semantic checking rather than in FIR.

@llvmbot
Copy link
Member

llvmbot commented Jan 29, 2025

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` program main type Base integer :: i = 88 end type
type, extends(Base) :: Child
    integer :: j = 99
end type

type(Child) :: c1(10)
type(Child) :: c2(3,5)
class(Base), allocatable :: b1(:)

c1 = (/ (Child(i,i+100), i=1,10) /)
allocate(Child::b1(2))

c2 = reshape(c1, (/3,5/), b1, (/2,1/))

end


Flang is issue an error as

error: loc("t.f":17:5): 'hlfir.reshape' op ARRAY and PAD must be of the same type
error: verification of lowering to FIR failed


While the complain is correct as the standard requires SOURCE and PAD to have the same declare and dynamic type, it should be a semantic checking rather than in FIR.
</details>

@klausler klausler self-assigned this Jan 30, 2025
klausler added a commit to klausler/llvm-project that referenced this issue Jan 30, 2025
Some errors aren't being caught, such as the case in the linked bug
where the PAD= argument to RESHAPE() didn't have the same declared
type as the ARRAY=; this led to a crash in lowering.  Refine the
"same type" testing logic for intrinsic procedures, and add a
better test.

Fixes llvm#124976.
klausler added a commit that referenced this issue Jan 31, 2025
Some errors aren't being caught, such as the case in the linked bug
where the PAD= argument to RESHAPE() didn't have the same declared type
as the ARRAY=; this led to a crash in lowering. Refine the "same type"
testing logic for intrinsic procedures, and add a better test.

Fixes #124976.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this issue Jan 31, 2025
… (#125133)

Some errors aren't being caught, such as the case in the linked bug
where the PAD= argument to RESHAPE() didn't have the same declared type
as the ARRAY=; this led to a crash in lowering. Refine the "same type"
testing logic for intrinsic procedures, and add a better test.

Fixes llvm/llvm-project#124976.
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