[flang-commits] [PATCH] D135218: [flang][runtime] Handle array components in NAMELIST input
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Oct 5 15:42:34 PDT 2022
klausler updated this revision to Diff 465581.
klausler added a comment.
Back out a needless change that has led to local test breakage.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135218/new/
https://reviews.llvm.org/D135218
Files:
flang/runtime/namelist.cpp
Index: flang/runtime/namelist.cpp
===================================================================
--- flang/runtime/namelist.cpp
+++ flang/runtime/namelist.cpp
@@ -310,7 +310,42 @@
type{addendum ? addendum->derivedType() : nullptr}) {
if (const typeInfo::Component *
comp{type->FindDataComponent(compName, std::strlen(compName))}) {
- comp->CreatePointerDescriptor(desc, source, handler);
+ bool createdDesc{false};
+ if (comp->rank() > 0 && source.rank() > 0) {
+ // If base and component are both arrays, the component name
+ // must be followed by subscripts; process them now.
+ std::size_t byteCount{0};
+ if (std::optional<char32_t> next{io.GetNextNonBlank(byteCount)};
+ next && *next == '(') {
+ io.HandleRelativePosition(byteCount); // skip over '('
+ StaticDescriptor<maxRank, true, 16> staticDesc;
+ Descriptor &tmpDesc{staticDesc.descriptor()};
+ comp->CreatePointerDescriptor(tmpDesc, source, handler);
+ if (!HandleSubscripts(io, desc, tmpDesc, compName)) {
+ return false;
+ }
+ createdDesc = true;
+ }
+ }
+ if (!createdDesc) {
+ comp->CreatePointerDescriptor(desc, source, handler);
+ }
+ if (source.rank() > 0) {
+ if (desc.rank() > 0) {
+ handler.SignalError(
+ "NAMELIST component reference '%%%s' of input group "
+ "item %s cannot be an array when its base is not scalar",
+ compName, name);
+ return false;
+ }
+ desc.raw().rank = source.rank();
+ for (int j{0}; j < source.rank(); ++j) {
+ const auto &srcDim{source.GetDimension(j)};
+ desc.GetDimension(j)
+ .SetBounds(1, srcDim.UpperBound())
+ .SetByteStride(srcDim.ByteStride());
+ }
+ }
return true;
} else {
handler.SignalError(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135218.465581.patch
Type: text/x-patch
Size: 2041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221005/099303ed/attachment.bin>
More information about the flang-commits
mailing list