[flang] fold LOGICAL intrinsic calls

Folding of LOGICAL intrinsic procedure was missing in the front-end causing
crash when using it in parameter expressions.
Simply fold LOGICAL calls to evaluate::Convert<T>.

Differential Revision: https://reviews.llvm.org/D99346
This commit is contained in:
Jean Perier 2021-03-25 18:36:06 +01:00
parent 7f5abb6373
commit 27899112c6
2 changed files with 7 additions and 0 deletions

View File

@ -106,6 +106,10 @@ Expr<Type<TypeCategory::Logical, KIND>> FoldIntrinsicFunction(
}
}
}
} else if (name == "logical") {
if (auto *expr{UnwrapExpr<Expr<SomeLogical>>(args[0])}) {
return Fold(context, ConvertToType<T>(std::move(*expr)));
}
} else if (name == "merge") {
return FoldMerge<T>(context, std::move(funcRef));
} else if (name == "__builtin_ieee_support_datatype" ||

View File

@ -30,6 +30,9 @@ module m
logical, parameter :: test_neqv3 = .NOT.(.false..NEQV..false.)
logical, parameter :: test_neqv4 = .NOT.(.true..NEQV..true.)
logical, parameter :: test_logical1 = logical(logical(.true., 2))
logical, parameter :: test_logical2 = .NOT.logical(logical(.false., 2))
! Check integer intrinsic operator folding
! Check integer relational intrinsic operation folding