Issue |
142481
|
Summary |
[flang] Defined assignment resolution error
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
DanielCChen
|
Consider the following code:
```
module m
type base
integer :: i
contains
procedure :: bassgn
generic :: assignment(=) => bassgn
end type
type, extends(base) :: child
integer :: j
contains
procedure :: cassgn
generic :: assignment(=) => cassgn
end type
type container
class(base), allocatable :: b1
class(child), allocatable :: c1
end type
contains
impure elemental subroutine bassgn ( a, b )
class(base), intent(out) :: a
type(base), intent(in) :: b
a%i = b%i + 1
select type ( a )
type is ( child )
a%j = b%i + 2
end select
end subroutine
impure elemental subroutine cassgn ( a, b )
class(child), intent(out) :: a
type(child), intent(in) :: b
a%i = b%i + 2
a%j = b%j + 2
end subroutine
end module
program genericAssignmentDtIntrinAssgn029
use m
type(container) :: c1, c2, c3
pointer :: c2
allocatable :: c3
allocate ( c2, c3 )
allocate ( c2%b1, source = child(1,2) )
allocate ( c2%c1, source = child(9,10))
c1 = c2
c3 = c1
select type ( g => c1%b1 )
type is ( child )
select type ( h => c1%c1 )
type is ( child )
print *, g%j !! ERROR
end select
end select
select type ( g => c3%b1 )
type is ( child )
select type ( h => c3%c1 )
type is ( child )
print *, g%j !! ERROR
end select
end select
end program
```
Expected output:
```
3
4
```
Flang outputs:
```
0
0
```
Both assignment `c1 = c2` and `c3 = c1` should resolve to `cassgn` for the `b1` component as its dynamic type is `child`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs