[flang-commits] [PATCH] D154377: [flang] Don't warn about a NaN argument to ISNAN()
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jul 3 10:30:47 PDT 2023
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
Don't emit a warning when a compile-time constant argument to
ISNAN() or IEEE_IS_NAN() is a NaN.
https://reviews.llvm.org/D154377
Files:
flang/lib/Evaluate/fold-logical.cpp
flang/test/Evaluate/errors01.f90
Index: flang/test/Evaluate/errors01.f90
===================================================================
--- flang/test/Evaluate/errors01.f90
+++ flang/test/Evaluate/errors01.f90
@@ -165,5 +165,7 @@
integer, parameter :: bad4 = dim(huge(1),-1)
!CHECK: warning: overflow on REAL(8) to REAL(4) conversion
x = 1.D40
+ !CHECK-NOT: warning: invalid argument
+ if (.not. isnan(real(z'ffffffffffffffff',8))) stop
end subroutine
end module
Index: flang/lib/Evaluate/fold-logical.cpp
===================================================================
--- flang/lib/Evaluate/fold-logical.cpp
+++ flang/lib/Evaluate/fold-logical.cpp
@@ -155,10 +155,11 @@
}
}
} else if (name == "isnan" || name == "__builtin_ieee_is_nan") {
- using DefaultReal = Type<TypeCategory::Real, 4>;
// Only replace the type of the function if we can do the fold
if (args[0] && args[0]->UnwrapExpr() &&
IsActuallyConstant(*args[0]->UnwrapExpr())) {
+ auto restorer{context.messages().DiscardMessages()};
+ using DefaultReal = Type<TypeCategory::Real, 4>;
return FoldElementalIntrinsic<T, DefaultReal>(context, std::move(funcRef),
ScalarFunc<T, DefaultReal>([](const Scalar<DefaultReal> &x) {
return Scalar<T>{x.IsNotANumber()};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154377.536840.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230703/c9c18d4f/attachment-0001.bin>
More information about the flang-commits
mailing list