[flang] Fix crash in fuzzing test (#122189)

Fixes https://github.com/llvm/llvm-project/issues/121972.
This commit is contained in:
Peter Klausler
2025-01-14 10:40:39 -08:00
committed by GitHub
parent bf23ae6d38
commit c8202db43a
2 changed files with 8 additions and 0 deletions

View File

@@ -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}))}) {

View File

@@ -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