[flang-commits] [flang] Get the BoxType from the RHS instead of LHS for polymorphic pointer assignment inside FORALL. (PR #164279)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 21 01:58:33 PDT 2025
https://github.com/jeanPerier requested changes to this pull request.
Actually, I now remember why this code was using the LHS type, and this is to cover the case where the RHS is polymorphic and the LHS is not... (the opposite use case).
Here is a modified test from the issue that passes with flang-trunk but would fail after this patch:
```
module m
TYPE :: DT
TYPE(DT), POINTER :: Ptr(:) => NULL()
END TYPE
TYPE, EXTENDS(DT) :: DT1
END TYPE
contains
subroutine test(Tar1)
CLASS(DT), TARGET :: Tar1(:)
TYPE(DT) :: T(10)
integer :: I
!DO I = 1, 10
FORALL (I=1:10)
T(I)%Ptr => Tar1
END FORALL
!end do
call test_type(T(1)%Ptr)
DO I = 1, 10
END DO
end subroutine
subroutine test_type(Tptr)
class(DT) :: Tptr(:)
SELECT TYPE (aa => Tptr)
TYPE IS (DT1)
print*, "in type is"
CLASS DEFAULT
print*, "in class default"
END SELECT
end subroutine
end module
use m
TYPE(DT1), TARGET :: Tar1(10)
call test(Tar1)
END
```
So I think you need to BaseBoxType change the type passed to genVariableBox only when the LHS is polymorphic.
https://github.com/llvm/llvm-project/pull/164279
More information about the flang-commits
mailing list