Added -Wfloat-equal option to the driver. This makes warnings about
floating point comparisons using == or != an opt-in rather than a default warning. Updated test case to use -Wfloat-equal. llvm-svn: 44053
This commit is contained in:
parent
07328f0b8b
commit
2272f72723
|
@ -356,6 +356,10 @@ static llvm::cl::opt<bool>
|
|||
WarnUnusedMacros("Wunused_macros",
|
||||
llvm::cl::desc("Warn for unused macros in the main translation unit"));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
WarnFloatEqual("Wfloat-equal",
|
||||
llvm::cl::desc("Warn about equality comparisons of floating point values."));
|
||||
|
||||
/// InitializeDiagnostics - Initialize the diagnostic object, based on the
|
||||
/// current command line option settings.
|
||||
static void InitializeDiagnostics(Diagnostic &Diags) {
|
||||
|
@ -366,6 +370,10 @@ static void InitializeDiagnostics(Diagnostic &Diags) {
|
|||
// Silence the "macro is not used" warning unless requested.
|
||||
if (!WarnUnusedMacros)
|
||||
Diags.setDiagnosticMapping(diag::pp_macro_not_used, diag::MAP_IGNORE);
|
||||
|
||||
// Silence "floating point comparison" warnings unless requested.
|
||||
if (!WarnFloatEqual)
|
||||
Diags.setDiagnosticMapping(diag::warn_floatingpoint_eq, diag::MAP_IGNORE);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
// RUN: clang -fsyntax-only -Wfloat-equal -verify %s
|
||||
|
||||
int foo(float x, float y) {
|
||||
return x == y; // expected-warning {{comparing floating point with ==}}
|
||||
|
|
Loading…
Reference in New Issue