[flang-commits] [flang] 08bfc00 - [flang] Don't warn about a NaN argument to ISNAN()
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Jul 3 13:25:54 PDT 2023
Author: Peter Klausler
Date: 2023-07-03T13:20:17-07:00
New Revision: 08bfc002885f874afb1e58814c27e2c461aa8130
URL: https://github.com/llvm/llvm-project/commit/08bfc002885f874afb1e58814c27e2c461aa8130
DIFF: https://github.com/llvm/llvm-project/commit/08bfc002885f874afb1e58814c27e2c461aa8130.diff
LOG: [flang] Don't warn about a NaN argument to ISNAN()
Don't emit a warning when a compile-time constant argument to
ISNAN() or IEEE_IS_NAN() is a NaN.
Differential Revision: https://reviews.llvm.org/D154377
Added:
Modified:
flang/lib/Evaluate/fold-logical.cpp
flang/test/Evaluate/errors01.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/fold-logical.cpp b/flang/lib/Evaluate/fold-logical.cpp
index e90090577b6ed1..129a8fc40577d0 100644
--- a/flang/lib/Evaluate/fold-logical.cpp
+++ b/flang/lib/Evaluate/fold-logical.cpp
@@ -155,10 +155,11 @@ Expr<Type<TypeCategory::Logical, KIND>> FoldIntrinsicFunction(
}
}
} 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()};
diff --git a/flang/test/Evaluate/errors01.f90 b/flang/test/Evaluate/errors01.f90
index cbb05ffb72b579..6f1f056b2652b5 100644
--- a/flang/test/Evaluate/errors01.f90
+++ b/flang/test/Evaluate/errors01.f90
@@ -176,7 +176,21 @@ subroutine warnings
integer, parameter :: bad4 = dim(huge(1),-1)
!CHECK: warning: HYPOT intrinsic folding overflow
real, parameter :: bad5 = hypot(huge(0.), huge(0.))
+ !CHECK: warning: SUM() of INTEGER(4) data overflowed
+ integer, parameter :: bad6 = sum([huge(1),huge(1)])
+ !CHECK: warning: SUM() of REAL(4) data overflowed
+ real, parameter :: bad7 = sum([huge(1.),huge(1.)])
+ !CHECK: warning: SUM() of COMPLEX(4) data overflowed
+ complex, parameter :: bad8 = sum([(huge(1.),0.),(huge(1.),0.)])
+ !CHECK: warning: PRODUCT() of INTEGER(4) data overflowed
+ integer, parameter :: bad9 = product([huge(1),huge(1)])
+ !CHECK: warning: PRODUCT() of REAL(4) data overflowed
+ real, parameter :: bad10 = product([huge(1.),huge(1.)])
+ !CHECK: warning: PRODUCT() of COMPLEX(4) data overflowed
+ complex, parameter :: bad11 = product([(huge(1.),0.),(huge(1.),0.)])
!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
More information about the flang-commits
mailing list