[clang-tools-extra] [clang] [llvm] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 09:20:34 PST 2024


================
@@ -70,6 +70,10 @@ def warn_pragma_debug_missing_argument : Warning<
 def warn_pragma_debug_unexpected_argument : Warning<
   "unexpected argument to debug command">, InGroup<IgnoredPragmas>;
 
+def warn_fp_nan_inf_when_disabled : Warning<
+  "use of %select{infinity|NaN}0%select{| via a macro}1 results in undefined behavior "
+  "due to the currently enabled floating-point options">,
+  InGroup<DiagGroup<"nan-and-infinity-disabled">>;
----------------
AaronBallman wrote:

```suggestion
def warn_fp_nan_inf_when_disabled : Warning<
  "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
  "due to the currently enabled floating-point options">,
  InGroup<DiagGroup<"nan-infinity-disabled">>;
```
Sorry for still puttering around with what color to paint the bikeshed, but I think this might be slightly more concise wording and a somewhat better diagnostic group.

https://github.com/llvm/llvm-project/pull/76873


More information about the llvm-commits mailing list