diff options
author | Peter Klausler <pklausler@nvidia.com> | 2022-05-03 02:56:20 +0300 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2022-05-10 02:39:15 +0300 |
commit | 6f14dbedd942d9a30abcf2e067083a826eab23db (patch) | |
tree | b86679254ac25e7414d11a93d38fdf639e0712d4 /flang | |
parent | b554c643c5bc3688fd0dfa646480b8337023a6fd (diff) |
[flang] Fix to UnwrapConvertedExpr()
The utility UnwrapConvertedExpr() was failing to unwrap a
converted TypeParamInquiry operation when called from runtime
derived type description table construction, leading to an
abort in semantics.
Differential Revision: https://reviews.llvm.org/D125119
Diffstat (limited to 'flang')
-rw-r--r-- | flang/include/flang/Evaluate/tools.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h index 77810da17846..ac75de8899bb 100644 --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -219,16 +219,22 @@ auto UnwrapConvertedExpr(B &x) -> common::Constify<A, B> * { } else if constexpr (std::is_same_v<Ty, Expr<SomeType>>) { return common::visit( [](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u); - } else if constexpr (!common::HasMember<A, TypelessExpression>) { - using Result = ResultType<A>; - if constexpr (std::is_same_v<Ty, Expr<Result>> || - std::is_same_v<Ty, Expr<SomeKind<Result::category>>>) { + } else { + using DesiredResult = ResultType<A>; + if constexpr (std::is_same_v<Ty, Expr<DesiredResult>> || + std::is_same_v<Ty, Expr<SomeKind<DesiredResult::category>>>) { return common::visit( [](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u); - } else if constexpr (std::is_same_v<Ty, Parentheses<Result>> || - std::is_same_v<Ty, Convert<Result, Result::category>>) { - return common::visit( - [](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.left().u); + } else { + using ThisResult = ResultType<B>; + if constexpr (std::is_same_v<Ty, Expr<ThisResult>>) { + return common::visit( + [](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.u); + } else if constexpr (std::is_same_v<Ty, Parentheses<ThisResult>> || + std::is_same_v<Ty, Convert<ThisResult, DesiredResult::category>>) { + return common::visit( + [](auto &x) { return UnwrapConvertedExpr<A>(x); }, x.left().u); + } } } return nullptr; |