forked from OSchip/llvm-project
[flang] Fix folding of substring
Original-commit: flang-compiler/f18@62dc5e0c93 Reviewed-on: https://github.com/flang-compiler/f18/pull/449 Tree-same-pre-rewrite: false
This commit is contained in:
parent
52d46695fc
commit
bb83471e96
|
@ -158,8 +158,13 @@ DataRef FoldOperation(FoldingContext &context, DataRef &&dataRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Substring FoldOperation(FoldingContext &context, Substring &&substring) {
|
Substring FoldOperation(FoldingContext &context, Substring &&substring) {
|
||||||
std::optional<Expr<SubscriptInteger>> lower{Fold(context, substring.lower())};
|
std::optional<Expr<SubscriptInteger>> lower, upper;
|
||||||
std::optional<Expr<SubscriptInteger>> upper{Fold(context, substring.upper())};
|
if (auto *p{substring.lower()}) {
|
||||||
|
lower = Fold(context, std::move(*p));
|
||||||
|
}
|
||||||
|
if (auto *p{substring.upper()}) {
|
||||||
|
upper = Fold(context, std::move(*p));
|
||||||
|
}
|
||||||
if (const DataRef * dataRef{substring.GetParentIf<DataRef>()}) {
|
if (const DataRef * dataRef{substring.GetParentIf<DataRef>()}) {
|
||||||
return Substring{FoldOperation(context, DataRef{*dataRef}),
|
return Substring{FoldOperation(context, DataRef{*dataRef}),
|
||||||
std::move(lower), std::move(upper)};
|
std::move(lower), std::move(upper)};
|
||||||
|
|
Loading…
Reference in New Issue