[PATCH] D122155: Add warning when eval-method is set in the presence of value unsafe floating-point calculations.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 07:13:21 PDT 2022


aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:127-129
+def warn_eval_method_setting_is_meaningless_in_value_unsafe_context : Warning<
+  "setting the eval method via '-ffp-eval-method' or '#pragma clang fp eval_method' "
+  "has not effect when numeric results of floating-point calculations aren't value-safe.">, InGroup<Pragmas>;
----------------
I think we should split the diagnostics into two -- one as a Sema diagnostic (as a warning for the pragma case, in the Pragmas diagnostic group) and one as a Frontend diagnostic (as an error, for the command line case).

Basically, I think we should treat the command line options as being mutually exclusive and handle it the same as any other "these options cannot be used together" situation.


================
Comment at: clang/lib/Sema/Sema.cpp:259-260
                               getLangOpts().getFPEvalMethod());
+    if (getLangOpts().ApproxFunc || getLangOpts().AllowFPReassoc ||
+        getLangOpts().AllowRecip)
+      // When these options are used, the compiler is allowed to make
----------------
I don't think this is the right place to diagnose this -- these are command line options that don't play well together, so they should be handled when processing command line options.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122155/new/

https://reviews.llvm.org/D122155



More information about the cfe-commits mailing list