[flang-commits] [flang] c8202db - [flang] Fix crash in fuzzing test (#122189)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 14 10:40:42 PST 2025
Author: Peter Klausler
Date: 2025-01-14T10:40:39-08:00
New Revision: c8202db43ad0cafdc59903dadc4ea9f95a73de9b
URL: https://github.com/llvm/llvm-project/commit/c8202db43ad0cafdc59903dadc4ea9f95a73de9b
DIFF: https://github.com/llvm/llvm-project/commit/c8202db43ad0cafdc59903dadc4ea9f95a73de9b.diff
LOG: [flang] Fix crash in fuzzing test (#122189)
Fixes https://github.com/llvm/llvm-project/issues/121972.
Added:
flang/test/Semantics/bug121972.f90
Modified:
flang/lib/Evaluate/tools.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 6bd623a690e380..2d0e1996632fc2 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1320,6 +1320,9 @@ template <TypeCategory TO, TypeCategory FROM>
static std::optional<Expr<SomeType>> DataConstantConversionHelper(
FoldingContext &context, const DynamicType &toType,
const Expr<SomeType> &expr) {
+ if (!IsValidKindOfIntrinsicType(FROM, toType.kind())) {
+ return std::nullopt;
+ }
DynamicType sizedType{FROM, toType.kind()};
if (auto sized{
Fold(context, ConvertToType(sizedType, Expr<SomeType>{expr}))}) {
diff --git a/flang/test/Semantics/bug121972.f90 b/flang/test/Semantics/bug121972.f90
new file mode 100644
index 00000000000000..a4c255ce2947ef
--- /dev/null
+++ b/flang/test/Semantics/bug121972.f90
@@ -0,0 +1,5 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+module acc_declare_test
+! ERROR: Initialization expression cannot be converted to declared type of 'ifcondition' from LOGICAL(4)
+ integer(16), parameter :: ifCondition = .FALSE.
+end module
More information about the flang-commits
mailing list