Skip to content

Commit c8202db

Browse files
authored
[flang] Fix crash in fuzzing test (#122189)
Fixes #121972.
1 parent bf23ae6 commit c8202db

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

flang/lib/Evaluate/tools.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,9 @@ template <TypeCategory TO, TypeCategory FROM>
13201320
static std::optional<Expr<SomeType>> DataConstantConversionHelper(
13211321
FoldingContext &context, const DynamicType &toType,
13221322
const Expr<SomeType> &expr) {
1323+
if (!IsValidKindOfIntrinsicType(FROM, toType.kind())) {
1324+
return std::nullopt;
1325+
}
13231326
DynamicType sizedType{FROM, toType.kind()};
13241327
if (auto sized{
13251328
Fold(context, ConvertToType(sizedType, Expr<SomeType>{expr}))}) {

flang/test/Semantics/bug121972.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
module acc_declare_test
3+
! ERROR: Initialization expression cannot be converted to declared type of 'ifcondition' from LOGICAL(4)
4+
integer(16), parameter :: ifCondition = .FALSE.
5+
end module

0 commit comments

Comments
 (0)