[flang-commits] [PATCH] D152212: [flang] Fix crash in shape analysis of PACK()
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jun 5 19:33:00 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7db4c583db63: [flang] Fix crash in shape analysis of PACK() (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152212/new/
https://reviews.llvm.org/D152212
Files:
flang/lib/Evaluate/shape.cpp
flang/test/Evaluate/errors01.f90
Index: flang/test/Evaluate/errors01.f90
===================================================================
--- flang/test/Evaluate/errors01.f90
+++ flang/test/Evaluate/errors01.f90
@@ -45,6 +45,7 @@
integer :: x(3)
!CHECK: error: Invalid 'vector=' argument in PACK: the 'mask=' argument has 3 true elements, but the vector has only 2 elements
x = pack(array, mask, [0,0])
+ x = pack(spread(array, x(1), x(2)), .true.) ! regression check, once crashed
end subroutine
subroutine s5
logical, parameter :: mask(2,3) = reshape([.false., .true., .true., .false., .false., .true.], shape(mask))
Index: flang/lib/Evaluate/shape.cpp
===================================================================
--- flang/lib/Evaluate/shape.cpp
+++ flang/lib/Evaluate/shape.cpp
@@ -902,18 +902,18 @@
if (maskShape->size() == 0) {
// Scalar MASK= -> [MERGE(SIZE(ARRAY=), 0, mask)]
if (auto arrayShape{(*this)(call.arguments().at(0))}) {
- auto arraySize{GetSize(std::move(*arrayShape))};
- CHECK(arraySize);
- ActualArguments toMerge{
- ActualArgument{AsGenericExpr(std::move(*arraySize))},
- ActualArgument{AsGenericExpr(ExtentExpr{0})},
- common::Clone(call.arguments().at(1))};
- auto specific{context_->intrinsics().Probe(
- CallCharacteristics{"merge"}, toMerge, *context_)};
- CHECK(specific);
- return Shape{ExtentExpr{FunctionRef<ExtentType>{
- ProcedureDesignator{std::move(specific->specificIntrinsic)},
- std::move(specific->arguments)}}};
+ if (auto arraySize{GetSize(std::move(*arrayShape))}) {
+ ActualArguments toMerge{
+ ActualArgument{AsGenericExpr(std::move(*arraySize))},
+ ActualArgument{AsGenericExpr(ExtentExpr{0})},
+ common::Clone(call.arguments().at(1))};
+ auto specific{context_->intrinsics().Probe(
+ CallCharacteristics{"merge"}, toMerge, *context_)};
+ CHECK(specific);
+ return Shape{ExtentExpr{FunctionRef<ExtentType>{
+ ProcedureDesignator{std::move(specific->specificIntrinsic)},
+ std::move(specific->arguments)}}};
+ }
}
} else {
// Non-scalar MASK= -> [COUNT(mask)]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152212.528664.patch
Type: text/x-patch
Size: 2466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230606/46b9ee30/attachment.bin>
More information about the flang-commits
mailing list