[flang-commits] [PATCH] D145248: [flang] Ensure that CLASS(*) component descriptors have addenda
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Mar 9 09:51:56 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG392173da3d15: [flang] Ensure that CLASS(*) component descriptors have addenda (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145248/new/
https://reviews.llvm.org/D145248
Files:
flang/lib/Semantics/compute-offsets.cpp
flang/runtime/derived.cpp
Index: flang/runtime/derived.cpp
===================================================================
--- flang/runtime/derived.cpp
+++ flang/runtime/derived.cpp
@@ -20,8 +20,8 @@
std::size_t elements{instance.Elements()};
std::size_t byteStride{instance.ElementBytes()};
int stat{StatOk};
- // Initialize data components in each element; the per-element iteration
- // constitutes the inner loops, not outer
+ // Initialize data components in each element; the per-element iterations
+ // constitute the inner loops, not the outer ones
std::size_t myComponents{componentDesc.Elements()};
for (std::size_t k{0}; k < myComponents; ++k) {
const auto &comp{
@@ -36,7 +36,14 @@
if (comp.genre() == typeInfo::Component::Genre::Automatic) {
stat = ReturnError(terminator, allocDesc.Allocate(), errMsg, hasStat);
if (stat == StatOk) {
- stat = Initialize(allocDesc, derived, terminator, hasStat, errMsg);
+ if (const DescriptorAddendum * addendum{allocDesc.Addendum()}) {
+ if (const auto *derived{addendum->derivedType()}) {
+ if (!derived->noInitializationNeeded()) {
+ stat = Initialize(
+ allocDesc, *derived, terminator, hasStat, errMsg);
+ }
+ }
+ }
}
if (stat != StatOk) {
break;
Index: flang/lib/Semantics/compute-offsets.cpp
===================================================================
--- flang/lib/Semantics/compute-offsets.cpp
+++ flang/lib/Semantics/compute-offsets.cpp
@@ -321,11 +321,12 @@
const Symbol &symbol, bool entire) -> SizeAndAlignment {
auto &targetCharacteristics{context_.targetCharacteristics()};
if (IsDescriptor(symbol)) {
- const auto *derived{
- evaluate::GetDerivedTypeSpec(evaluate::DynamicType::From(symbol))};
+ auto dyType{evaluate::DynamicType::From(symbol)};
+ const auto *derived{evaluate::GetDerivedTypeSpec(dyType)};
int lenParams{derived ? CountLenParameters(*derived) : 0};
+ bool needAddendum{derived || (dyType && dyType->IsUnlimitedPolymorphic())};
std::size_t size{runtime::Descriptor::SizeInBytes(
- symbol.Rank(), derived != nullptr, lenParams)};
+ symbol.Rank(), needAddendum, lenParams)};
return {size, targetCharacteristics.descriptorAlignment()};
}
if (IsProcedurePointer(symbol)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145248.503815.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230309/f0f71953/attachment-0001.bin>
More information about the flang-commits
mailing list