[clang] Fix INF/NAN warning. (PR #80290)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 1 08:07:20 PST 2024
================
@@ -2847,12 +2848,15 @@ class Preprocessor {
!SourceMgr.isInMainFile(Identifier.getLocation()))
emitRestrictExpansionWarning(Identifier);
- if (Info->getName() == "INFINITY")
- if (getLangOpts().NoHonorInfs)
- emitRestrictInfNaNWarning(Identifier, 0);
- if (Info->getName() == "NAN")
- if (getLangOpts().NoHonorNaNs)
- emitRestrictInfNaNWarning(Identifier, 1);
+ if (!IsIfnDef) {
+ bool UnsafeMath = getLangOpts().UnsafeFPMath;
+ if (Info->getName() == "INFINITY")
+ if (getLangOpts().NoHonorInfs)
+ emitRestrictInfNaNWarning(Identifier, 0, UnsafeMath);
+ if (Info->getName() == "NAN")
+ if (getLangOpts().NoHonorNaNs)
+ emitRestrictInfNaNWarning(Identifier, 1, UnsafeMath);
----------------
AaronBallman wrote:
```suggestion
bool UnsafeMath = getLangOpts().UnsafeFPMath;
if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
emitRestrictInfNaNWarning(Identifier, 0, UnsafeMath);
if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
emitRestrictInfNaNWarning(Identifier, 1, UnsafeMath);
```
https://github.com/llvm/llvm-project/pull/80290
More information about the cfe-commits
mailing list