[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:06:46 PDT 2020
PeteSteinfeld created this revision.
PeteSteinfeld added reviewers: klausler, tskeith.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When there are errors in the evaluation of every cosubscript expression in a
coindexed object, the compiler would crash. I fixed this by just checking to
see if there were errors in the evaluation of the cosubscripts before
constructing the `DataRef` for the coindexed object.
Repository:
rG LLVM Github Monorepo
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.276474.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200708/432d4781/attachment.bin>
More information about the llvm-commits
mailing list