forked from OSchip/llvm-project
[flang] Make subscript list argument a nullable pointer
Component::CreatePointerDescriptor unconditionally expects a vector of subscripts to be passed as an argument, but is called from NAMELIST input with a null pointer. Make that argument a nullable pointer, move it to the end of the argument list, and give it a default value of nullptr. Differential Revision: https://reviews.llvm.org/D113312
This commit is contained in:
parent
80f0bb5971
commit
6d44387e21
|
@ -193,9 +193,9 @@ void Assign(Descriptor &to, const Descriptor &from, Terminator &terminator) {
|
|||
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
|
||||
|
|
|
@ -249,7 +249,7 @@ static bool DefaultFormattedComponentIO(IoStatementState &io,
|
|||
StaticDescriptor<maxRank, true, 16 /*?*/> statDesc;
|
||||
Descriptor &desc{statDesc.descriptor()};
|
||||
component.CreatePointerDescriptor(
|
||||
desc, origDescriptor, origSubscripts, terminator);
|
||||
desc, origDescriptor, terminator, origSubscripts);
|
||||
return DescriptorIO<DIR>(io, desc);
|
||||
} else {
|
||||
// Component is itself a descriptor
|
||||
|
|
|
@ -236,7 +236,7 @@ static bool HandleComponent(IoStatementState &io, Descriptor &desc,
|
|||
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 @@ static bool HandleComponent(IoStatementState &io, Descriptor &desc,
|
|||
"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 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
|||
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();
|
||||
|
|
|
@ -116,11 +116,15 @@ void Component::EstablishDescriptor(Descriptor &descriptor,
|
|||
}
|
||||
|
||||
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<char>(subscripts) + offset_);
|
||||
if (subscripts) {
|
||||
descriptor.set_base_addr(container.Element<char>(subscripts) + offset_);
|
||||
} else {
|
||||
descriptor.set_base_addr(container.OffsetElement<char>() + offset_);
|
||||
}
|
||||
descriptor.raw().attribute = CFI_attribute_pointer;
|
||||
}
|
||||
|
||||
|
@ -167,12 +171,11 @@ static void DumpScalarCharacter(
|
|||
}
|
||||
|
||||
FILE *DerivedType::Dump(FILE *f) const {
|
||||
std::fprintf(
|
||||
f, "DerivedType @ 0x%p:\n", reinterpret_cast<const void *>(this));
|
||||
std::fprintf(f, "DerivedType @ %p:\n", reinterpret_cast<const void *>(this));
|
||||
const std::uint64_t *uints{reinterpret_cast<const std::uint64_t *>(this)};
|
||||
for (int j{0}; j < 64; ++j) {
|
||||
int offset{j * static_cast<int>(sizeof *uints)};
|
||||
std::fprintf(f, " [+%3d](0x%p) 0x%016jx", offset,
|
||||
std::fprintf(f, " [+%3d](%p) 0x%016jx", offset,
|
||||
reinterpret_cast<const void *>(&uints[j]),
|
||||
static_cast<std::uintmax_t>(uints[j]));
|
||||
if (offset == offsetof(DerivedType, binding_)) {
|
||||
|
@ -235,7 +238,7 @@ FILE *DerivedType::Dump(FILE *f) const {
|
|||
}
|
||||
|
||||
FILE *Component::Dump(FILE *f) const {
|
||||
std::fprintf(f, "Component @ 0x%p:\n", reinterpret_cast<const void *>(this));
|
||||
std::fprintf(f, "Component @ %p:\n", reinterpret_cast<const void *>(this));
|
||||
std::fputs(" name: ", f);
|
||||
DumpScalarCharacter(f, name(), "Component::name");
|
||||
if (genre_ == Genre::Data) {
|
||||
|
@ -252,7 +255,7 @@ FILE *Component::Dump(FILE *f) const {
|
|||
std::fprintf(f, " category %d kind %d rank %d offset 0x%zx\n", category_,
|
||||
kind_, rank_, static_cast<std::size_t>(offset_));
|
||||
if (initialization_) {
|
||||
std::fprintf(f, " initialization @ 0x%p:\n",
|
||||
std::fprintf(f, " initialization @ %p:\n",
|
||||
reinterpret_cast<const void *>(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 *Component::Dump(FILE *f) const {
|
|||
|
||||
FILE *SpecialBinding::Dump(FILE *f) const {
|
||||
std::fprintf(
|
||||
f, "SpecialBinding @ 0x%p:\n", reinterpret_cast<const void *>(this));
|
||||
f, "SpecialBinding @ %p:\n", reinterpret_cast<const void *>(this));
|
||||
switch (which_) {
|
||||
case Which::ScalarAssignment:
|
||||
std::fputs(" ScalarAssignment", f);
|
||||
|
@ -297,7 +300,7 @@ FILE *SpecialBinding::Dump(FILE *f) const {
|
|||
break;
|
||||
}
|
||||
std::fprintf(f, " isArgDescriptorSet: 0x%x\n", isArgDescriptorSet_);
|
||||
std::fprintf(f, " proc: 0x%p\n", reinterpret_cast<void *>(proc_));
|
||||
std::fprintf(f, " proc: %p\n", reinterpret_cast<void *>(proc_));
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,10 @@ public:
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue