[flang-commits] [flang] [flang][runtime] Fix SAME_TYPE_AS()/EXTENDS_TYPE_OF() for CLASS(*) (PR #67727)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Sep 28 14:34:48 PDT 2023
================
@@ -61,13 +61,9 @@ void RTNAME(PointerApplyMold)(
pointer.set_base_addr(nullptr);
pointer.raw().attribute = CFI_attribute_pointer;
pointer.raw().rank = rank;
- if (pointerAddendum) {
- if (mold.Addendum()) {
- // it was copied by operator=() above
- } else {
- pointer.raw().f18Addendum = true;
- pointerAddendum->set_derivedType(nullptr);
- }
+ if (pointerAddendum && !mold.Addendum()) {
+ pointer.raw().f18Addendum = true;
+ INTERNAL_CHECK(!pointerAddendum->derivedType());
----------------
vzakhari wrote:
Interesting. I did not think we could do it here, but apparently we can.
Tried this example:
```
module types
type :: t1
end type t1
end module types
program main
use types
call test()
contains
subroutine test()
class(*), pointer :: x
type(t1) :: y
allocate(x,mold=y)
allocate(x,mold=y)
end subroutine test
end program main
```
The compiler nullifies the pointer before calling `PointerApplyMold`. This seems to be redundant now, since we started initializing pointers (including the components of the derived types) by default.
Thank you for the additional changes!
https://github.com/llvm/llvm-project/pull/67727
More information about the flang-commits
mailing list