[flang-commits] [flang] 3ddfb68 - [flang] Prevent crash from unfoldable TRANSFER() (#92282)
via flang-commits
flang-commits at lists.llvm.org
Wed May 15 16:41:15 PDT 2024
Author: Peter Klausler
Date: 2024-05-15T16:41:12-07:00
New Revision: 3ddfb6807e905868a3a9df71fa5ea87309181270
URL: https://github.com/llvm/llvm-project/commit/3ddfb6807e905868a3a9df71fa5ea87309181270
DIFF: https://github.com/llvm/llvm-project/commit/3ddfb6807e905868a3a9df71fa5ea87309181270.diff
LOG: [flang] Prevent crash from unfoldable TRANSFER() (#92282)
When the MOLD= argument's type is polymorphic, the type of the result
cannot be known at compilation time, so the call cannot be folded even
when the SOURCE= is constant.
Fixes https://github.com/llvm/llvm-project/issues/92264.
Added:
Modified:
flang/lib/Evaluate/fold.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/fold.cpp b/flang/lib/Evaluate/fold.cpp
index ed88295819980..cf6262d9a7c65 100644
--- a/flang/lib/Evaluate/fold.cpp
+++ b/flang/lib/Evaluate/fold.cpp
@@ -272,6 +272,7 @@ std::optional<Expr<SomeType>> FoldTransfer(
}
}
if (sourceBytes && IsActuallyConstant(*source) && moldType && extents &&
+ !moldType->IsPolymorphic() &&
(moldLength || moldType->category() != TypeCategory::Character)) {
std::size_t elements{
extents->empty() ? 1 : static_cast<std::size_t>((*extents)[0])};
More information about the flang-commits
mailing list