]> granicus.if.org Git - clang/commitdiff
Added test cases for -Wfloat-equal to test comparisons against literals that can be
authorTed Kremenek <kremenek@apple.com>
Thu, 29 Nov 2007 01:00:11 +0000 (01:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 29 Nov 2007 01:00:11 +0000 (01:00 +0000)
represented exactly and inexactly by APFloats. For the former, we do not emit a
warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44425 91177308-0d34-0410-b5e6-96231b3b80d8

test/Sema/floating-point-compare.c

index ac8fed2d62e36dc892f60482bade3b7e2d3d7c2f..e44ff096b2e675f91c021092bd5bb1705b955847 100644 (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
-}
\ No newline at end of file
+}
+
+int f6(float x) {
+  return x == 0.0; // no-warning
+}
+
+int f7(float x) {
+  return x == 3.14159; // expected-warning {{comparing}}
+}