Issue |
134567
|
Summary |
[Flang] Incorrect execution result of EXTENDS_TYPE_OF intrinsic function
|
Labels |
flang
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang : 21.0.0(06cb7b1e14a117e8fe19b72689c8616c772c0807)/AArch64
```
As in the attached program, the two arguments supplied to `EXTENDS_TYPE_OF intrinsic function` appear to be different types defined in different modules.
According to `Fortran Standard 2023: 16.9.86 EXTENDS_TYPE_OF (A, MOLD)`, the result is false if `dynamic type` of `first argument (dmyptr)` is not an `extension type` of the `dynamic type` of `the second argument (baseobj)`.
Therefore, the execution result of Flang is probably incorrect.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
Polymorphism_2.f90:
```fortran
MODULE MODULE3
IMPLICIT NONE
LOGICAL::x
TYPE base
integer ::int1
END TYPE base
TYPE ,EXTENDS(base)::deriv
INTEGER :: int2
END TYPE deriv
END MODULE MODULE3
MODULE MODULE4
IMPLICIT NONE
TYPE base
INTEGER ::ii
END TYPE base
TYPE ,EXTENDS(base):: deriv
INTEGER :: kk
END TYPE deriv
END MODULE
PROGRAM MAIN
IMPLICIT NONE
INTERFACE
SUBROUTINE sub2
END SUBROUTINE sub2
END INTERFACE
call sub2()
END PROGRAM MAIN
SUBROUTINE sub1(dmyptr)
use MODULE3
CLASS(*)::dmyptr
TYPE(deriv)::baseobj
LOGICAL::res
res=EXTENDS_TYPE_OF(dmyptr,baseobj)
print*,'res = ', res
if(res .eqv. .false.) then
print*,'pass'
else
print*,'fail'
endif
END SUBROUTINE sub1
SUBROUTINE sub2()
use MODULE4
INTERFACE
SUBROUTINE sub1(dmy1)
CLASS(*)::dmy1
END SUBROUTINE sub1
end interface
CLASS(base),POINTER::ptr_base
TYPE(deriv),TARGET::tar_ty1
ptr_base=>tar_ty1
call sub1(ptr_base)
END SUBROUTINE sub2
```
```
$ flang Polymorphism_2.f90; ./a.out
res = T
fail
$
```
```
$ gfortran Polymorphism_2.f90; ./a.out
res = F
pass
$
```
```
$ ifx Polymorphism_2.f90; ./a.out
res = F
pass
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs