Added test cases for -Wfloat-equal to test comparisons against literals that can be

represented exactly and inexactly by APFloats. For the former, we do not emit a
warning.

llvm-svn: 44425
This commit is contained in:
Ted Kremenek 2007-11-29 01:00:11 +00:00
parent eda40e273e
commit 0865d8a5d0
1 changed files with 14 additions and 6 deletions

View File

@ -1,21 +1,29 @@
// RUN: clang -fsyntax-only -Wfloat-equal -verify %s
int foo(float x, float y) {
int f1(float x, float y) {
return x == y; // expected-warning {{comparing floating point with ==}}
}
int bar(float x, float y) {
int f2(float x, float y) {
return x != y; // expected-warning {{comparing floating point with ==}}
}
int qux(float x) {
int f3(float x) {
return x == x; // no-warning
}
int baz(float x) {
int f4(float x) {
return x == 0.0; // expected-warning {{comparing}}
}
int taz(float x) {
int f5(float x) {
return x == __builtin_inf(); // no-warning
}
int f6(float x) {
return x == 0.0; // no-warning
}
int f7(float x) {
return x == 3.14159; // expected-warning {{comparing}}
}