mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-03 14:22:23 +00:00
[flang] Fix to IsDescriptor
IsDescriptor was returning false for a component whose shape depended on a length parameter. Change it to return true for any array with non-constant bounds. Differential Revision: https://reviews.llvm.org/D79349
This commit is contained in:
parent
c54c6ee1a7
commit
7ccc7e5672
@ -223,6 +223,7 @@ struct ArraySpec : public std::vector<ShapeSpec> {
|
||||
bool IsImpliedShape() const;
|
||||
bool IsAssumedSize() const;
|
||||
bool IsAssumedRank() const;
|
||||
bool IsConstantShape() const; // explicit shape with constant bounds
|
||||
|
||||
private:
|
||||
// Check non-empty and predicate is true for each element.
|
||||
|
@ -31,13 +31,8 @@ static bool IsDescriptor(const ObjectEntityDetails &details) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (details.IsAssumedShape() || details.IsDeferredShape() ||
|
||||
details.IsAssumedRank()) {
|
||||
return true;
|
||||
}
|
||||
// TODO: Explicit shape component array dependent on length parameter
|
||||
// TODO: Automatic (adjustable) arrays - are they descriptors?
|
||||
return false;
|
||||
return !details.shape().empty() && !details.shape().IsConstantShape();
|
||||
}
|
||||
|
||||
static bool IsDescriptor(const ProcEntityDetails &details) {
|
||||
|
@ -507,6 +507,13 @@ bool ArraySpec::IsAssumedSize() const {
|
||||
bool ArraySpec::IsAssumedRank() const {
|
||||
return Rank() == 1 && front().lbound().isAssumed();
|
||||
}
|
||||
bool ArraySpec::IsConstantShape() const {
|
||||
return CheckAll([](const ShapeSpec &x) {
|
||||
const auto &lb{x.lbound().GetExplicit()};
|
||||
const auto &ub{x.ubound().GetExplicit()};
|
||||
return lb && ub && IsConstantExpr(*lb) && IsConstantExpr(*ub);
|
||||
});
|
||||
}
|
||||
|
||||
llvm::raw_ostream &operator<<(
|
||||
llvm::raw_ostream &os, const ArraySpec &arraySpec) {
|
||||
|
@ -49,4 +49,6 @@ subroutine s5(n)
|
||||
end type
|
||||
type(t1(n)) :: x1 !CHECK: x1 size=48 offset=
|
||||
type(t2(n,n)) :: x2 !CHECK: x2 size=56 offset=
|
||||
!CHECK: a size=48 offset=0:
|
||||
!CHECK: b size=72 offset=0:
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user