[flang-commits] [PATCH] D112347: [flang] Fix NAMELIST input bug with multiple subscript triplets
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Oct 22 14:50:48 PDT 2021
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
NAMELIST input can contain array subscripts with triplet notation.
The calculation of the default effective stride for the constructed
array descriptor was simply incorrect after the first dimension.
https://reviews.llvm.org/D112347
Files:
flang/runtime/namelist.cpp
Index: flang/runtime/namelist.cpp
===================================================================
--- flang/runtime/namelist.cpp
+++ flang/runtime/namelist.cpp
@@ -10,6 +10,7 @@
#include "descriptor-io.h"
#include "io-stmt.h"
#include "flang/Runtime/io-api.h"
+#include <algorithm>
#include <cstring>
#include <limits>
@@ -133,7 +134,7 @@
// ambiguous within the parentheses.
SubscriptValue lower[maxRank], upper[maxRank], stride[maxRank];
int j{0};
- std::size_t elemLen{source.ElementBytes()};
+ std::size_t contiguousStride{source.ElementBytes()};
bool ok{true};
std::optional<char32_t> ch{io.GetNextNonBlank()};
for (; ch && *ch != ')'; ++j) {
@@ -142,7 +143,9 @@
const Dimension &dim{source.GetDimension(j)};
dimLower = dim.LowerBound();
dimUpper = dim.UpperBound();
- dimStride = elemLen ? dim.ByteStride() / elemLen : 1;
+ dimStride =
+ dim.ByteStride() / std::max<SubscriptValue>(contiguousStride, 1);
+ contiguousStride *= dim.Extent();
} else if (ok) {
handler.SignalError(
"Too many subscripts for rank-%d NAMELIST group item '%s'",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112347.381663.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211022/da7cb446/attachment.bin>
More information about the flang-commits
mailing list