[PATCH] D83410: [flang] Fix a crash when cosubscript list is empty
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 10:12:00 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9520b6c8ab63: [flang] Fix a crash when cosubscript list is empty (authored by PeteSteinfeld).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83410/new/
https://reviews.llvm.org/D83410
Files:
flang/lib/Semantics/expression.cpp
flang/test/Semantics/resolve94.f90
Index: flang/test/Semantics/resolve94.f90
===================================================================
--- flang/test/Semantics/resolve94.f90
+++ flang/test/Semantics/resolve94.f90
@@ -13,6 +13,7 @@
integer, dimension(4) :: intArray
integer :: intScalarCoarray[*]
integer :: intCoarray[3, 4, *]
+ integer :: smallIntCoarray[4, *]
intCoVar = 343
! OK
rVar1 = rCoarray[1,2,3]
@@ -20,6 +21,8 @@
rVar1 = rCoarray[1,2]
!ERROR: Must have INTEGER type, but is REAL(4)
rVar1 = rCoarray[1,2,3.4]
+ !ERROR: Must have INTEGER type, but is REAL(4)
+ iVar1 = smallIntCoarray[3.4]
!ERROR: Must be a scalar value, but is a rank-1 array
rVar1 = rCoarray[1,intArray,3]
! OK
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -1089,15 +1089,17 @@
std::get<std::list<parser::ImageSelectorSpec>>(x.imageSelector.t)) {
std::visit(
common::visitors{
- [&](const auto &x) {Analyze(x.v); },
+ [&](const auto &x) { Analyze(x.v); },
},
imageSelSpec.u);
}
// Reverse the chain of symbols so that the base is first and coarray
// ultimate component is last.
- return Designate(
- DataRef{CoarrayRef{SymbolVector{reversed.crbegin(), reversed.crend()},
- std::move(subscripts), std::move(cosubscripts)}});
+ if (cosubsOk) {
+ return Designate(
+ DataRef{CoarrayRef{SymbolVector{reversed.crbegin(), reversed.crend()},
+ std::move(subscripts), std::move(cosubscripts)}});
+ }
}
return std::nullopt;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83410.276477.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200708/d69e7902/attachment.bin>
More information about the llvm-commits
mailing list