mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 08:16:47 +00:00
[flang] Fix crash in fuzzed input program (#122193)
Fixes https://github.com/llvm/llvm-project/issues/121971.
This commit is contained in:
parent
dcc141bc0b
commit
bf23ae6d38
@ -566,13 +566,13 @@ MaybeExtentExpr GetExtent(const Subscript &subscript, const NamedEntity &base,
|
||||
MaybeExtentExpr{triplet.stride()});
|
||||
},
|
||||
[&](const IndirectSubscriptIntegerExpr &subs) -> MaybeExtentExpr {
|
||||
if (auto shape{GetShape(subs.value())}) {
|
||||
if (GetRank(*shape) > 0) {
|
||||
CHECK(GetRank(*shape) == 1); // vector-valued subscript
|
||||
return std::move(shape->at(0));
|
||||
}
|
||||
if (auto shape{GetShape(subs.value())};
|
||||
shape && GetRank(*shape) == 1) {
|
||||
// vector-valued subscript
|
||||
return std::move(shape->at(0));
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
},
|
||||
subscript.u);
|
||||
|
10
flang/test/Semantics/bug121971.f90
Normal file
10
flang/test/Semantics/bug121971.f90
Normal file
@ -0,0 +1,10 @@
|
||||
! RUN: %python %S/test_errors.py %s %flang_fc1
|
||||
subroutine subr(a,b,n,m)
|
||||
real n,m
|
||||
!ERROR: Must have INTEGER type, but is REAL(4)
|
||||
!ERROR: Must have INTEGER type, but is REAL(4)
|
||||
integer a(n,m)
|
||||
!ERROR: Rank of left-hand side is 2, but right-hand side has rank 1
|
||||
!ERROR: Subscript expression has rank 2 greater than 1
|
||||
a = a(a,j)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user