[flang-commits] [flang] [flang][runtime] Establish derived type desc properly. (PR #67623)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Sep 28 08:52:21 PDT 2023
================
@@ -96,12 +96,19 @@ void Descriptor::Establish(const typeInfo::DerivedType &dt, void *p, int rank,
OwningPtr<Descriptor> Descriptor::Create(TypeCode t, std::size_t elementBytes,
void *p, int rank, const SubscriptValue *extent,
- ISO::CFI_attribute_t attribute, int derivedTypeLenParameters) {
- std::size_t bytes{SizeInBytes(rank, true, derivedTypeLenParameters)};
+ ISO::CFI_attribute_t attribute, bool addendum,
+ const typeInfo::DerivedType *dt) {
Terminator terminator{__FILE__, __LINE__};
+ RUNTIME_CHECK(terminator, t.IsDerived() == (dt != nullptr));
+ int derivedTypeLenParameters = dt ? dt->LenParameters() : 0;
+ std::size_t bytes{SizeInBytes(rank, addendum, derivedTypeLenParameters)};
Descriptor *result{
reinterpret_cast<Descriptor *>(AllocateMemoryOrCrash(terminator, bytes))};
- result->Establish(t, elementBytes, p, rank, extent, attribute, true);
----------------
vzakhari wrote:
Do you mean in the case like this?
```
program main
call test()
contains
subroutine test()
class(*), allocatable :: c(:)
integer :: i
i = 7
allocate(c(2), source=i)
select type (x => c)
type is (integer)
print *, x
end select
end subroutine test
end program main
```
The resulting descriptor for `c` does not have the addendum.
https://github.com/llvm/llvm-project/pull/67623
More information about the flang-commits
mailing list