Index: flang/runtime/assign.cpp =================================================================== --- flang/runtime/assign.cpp +++ flang/runtime/assign.cpp @@ -193,9 +193,9 @@ Descriptor &fromCompDesc{statDesc[1].descriptor()}; for (std::size_t j{0}; j < toElements; ++j, to.IncrementSubscripts(toAt), from.IncrementSubscripts(fromAt)) { - comp.CreatePointerDescriptor(toCompDesc, to, toAt, terminator); + comp.CreatePointerDescriptor(toCompDesc, to, terminator, toAt); comp.CreatePointerDescriptor( - fromCompDesc, from, fromAt, terminator); + fromCompDesc, from, terminator, fromAt); Assign(toCompDesc, fromCompDesc, terminator); } } else { // Component has intrinsic type; simply copy raw bytes Index: flang/runtime/descriptor-io.h =================================================================== --- flang/runtime/descriptor-io.h +++ flang/runtime/descriptor-io.h @@ -249,7 +249,7 @@ StaticDescriptor statDesc; Descriptor &desc{statDesc.descriptor()}; component.CreatePointerDescriptor( - desc, origDescriptor, origSubscripts, terminator); + desc, origDescriptor, terminator, origSubscripts); return DescriptorIO(io, desc); } else { // Component is itself a descriptor Index: flang/runtime/namelist.cpp =================================================================== --- flang/runtime/namelist.cpp +++ flang/runtime/namelist.cpp @@ -236,7 +236,7 @@ type{addendum ? addendum->derivedType() : nullptr}) { if (const typeInfo::Component * comp{type->FindDataComponent(compName, std::strlen(compName))}) { - comp->CreatePointerDescriptor(desc, source, nullptr, handler); + comp->CreatePointerDescriptor(desc, source, handler); return true; } else { handler.SignalError( @@ -244,6 +244,10 @@ "a component of its derived type", compName, name); } + } else if (source.type().IsDerived()) { + handler.Crash("Derived type object '%s' in NAMELIST is missing its " + "derived type information!", + name); } else { handler.SignalError("NAMELIST component reference '%%%s' of input group " "item %s for non-derived type", @@ -320,9 +324,14 @@ Descriptor &mutableDescriptor{staticDesc[whichStaticDesc].descriptor()}; whichStaticDesc ^= 1; if (*next == '(') { - HandleSubscripts(io, mutableDescriptor, *useDescriptor, name); + if (!(HandleSubscripts( + io, mutableDescriptor, *useDescriptor, name))) { + return false; + } } else { - HandleComponent(io, mutableDescriptor, *useDescriptor, name); + if (!HandleComponent(io, mutableDescriptor, *useDescriptor, name)) { + return false; + } } useDescriptor = &mutableDescriptor; next = io.GetCurrentChar(); Index: flang/runtime/type-info.h =================================================================== --- flang/runtime/type-info.h +++ flang/runtime/type-info.h @@ -86,9 +86,10 @@ void EstablishDescriptor( Descriptor &, const Descriptor &container, Terminator &) const; - // Creates a pointer descriptor from this component description. + // Creates a pointer descriptor from this component description, possibly + // with subscripts void CreatePointerDescriptor(Descriptor &, const Descriptor &container, - const SubscriptValue[], Terminator &) const; + Terminator &, const SubscriptValue * = nullptr) const; FILE *Dump(FILE * = stdout) const; Index: flang/runtime/type-info.cpp =================================================================== --- flang/runtime/type-info.cpp +++ flang/runtime/type-info.cpp @@ -116,11 +116,15 @@ } void Component::CreatePointerDescriptor(Descriptor &descriptor, - const Descriptor &container, const SubscriptValue subscripts[], - Terminator &terminator) const { + const Descriptor &container, Terminator &terminator, + const SubscriptValue *subscripts) const { RUNTIME_CHECK(terminator, genre_ == Genre::Data); EstablishDescriptor(descriptor, container, terminator); - descriptor.set_base_addr(container.Element(subscripts) + offset_); + if (subscripts) { + descriptor.set_base_addr(container.Element(subscripts) + offset_); + } else { + descriptor.set_base_addr(container.OffsetElement() + offset_); + } descriptor.raw().attribute = CFI_attribute_pointer; } @@ -167,12 +171,11 @@ } FILE *DerivedType::Dump(FILE *f) const { - std::fprintf( - f, "DerivedType @ 0x%p:\n", reinterpret_cast(this)); + std::fprintf(f, "DerivedType @ %p:\n", reinterpret_cast(this)); const std::uint64_t *uints{reinterpret_cast(this)}; for (int j{0}; j < 64; ++j) { int offset{j * static_cast(sizeof *uints)}; - std::fprintf(f, " [+%3d](0x%p) 0x%016jx", offset, + std::fprintf(f, " [+%3d](%p) 0x%016jx", offset, reinterpret_cast(&uints[j]), static_cast(uints[j])); if (offset == offsetof(DerivedType, binding_)) { @@ -235,7 +238,7 @@ } FILE *Component::Dump(FILE *f) const { - std::fprintf(f, "Component @ 0x%p:\n", reinterpret_cast(this)); + std::fprintf(f, "Component @ %p:\n", reinterpret_cast(this)); std::fputs(" name: ", f); DumpScalarCharacter(f, name(), "Component::name"); if (genre_ == Genre::Data) { @@ -252,7 +255,7 @@ std::fprintf(f, " category %d kind %d rank %d offset 0x%zx\n", category_, kind_, rank_, static_cast(offset_)); if (initialization_) { - std::fprintf(f, " initialization @ 0x%p:\n", + std::fprintf(f, " initialization @ %p:\n", reinterpret_cast(initialization_)); for (int j{0}; j < 128; j += sizeof(std::uint64_t)) { std::fprintf(f, " [%3d] 0x%016jx\n", j, @@ -265,7 +268,7 @@ FILE *SpecialBinding::Dump(FILE *f) const { std::fprintf( - f, "SpecialBinding @ 0x%p:\n", reinterpret_cast(this)); + f, "SpecialBinding @ %p:\n", reinterpret_cast(this)); switch (which_) { case Which::ScalarAssignment: std::fputs(" ScalarAssignment", f); @@ -297,7 +300,7 @@ break; } std::fprintf(f, " isArgDescriptorSet: 0x%x\n", isArgDescriptorSet_); - std::fprintf(f, " proc: 0x%p\n", reinterpret_cast(proc_)); + std::fprintf(f, " proc: %p\n", reinterpret_cast(proc_)); return f; }