summaryrefslogtreecommitdiff
path: root/clang/test/Sema/floating-point-compare.c
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Sema/floating-point-compare.c
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Sema/floating-point-compare.c')
-rw-r--r--clang/test/Sema/floating-point-compare.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/Sema/floating-point-compare.c b/clang/test/Sema/floating-point-compare.c
new file mode 100644
index 0000000..60f971c
--- /dev/null
+++ b/clang/test/Sema/floating-point-compare.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s
+
+int f1(float x, float y) {
+ return x == y; // expected-warning {{comparing floating point with ==}}
+}
+
+int f2(float x, float y) {
+ return x != y; // expected-warning {{comparing floating point with ==}}
+}
+
+int f3(float x) {
+ return x == x; // no-warning
+}
+
+int f4(float x) {
+ return x == 0.0; // no-warning {{comparing}}
+}
+
+int f5(float x) {
+ return x == __builtin_inf(); // no-warning
+}
+
+int f7(float x) {
+ return x == 3.14159; // expected-warning {{comparing}}
+}