Ted Kremenek | db87bca | 2007-11-13 18:37:02 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -Wfloat-equal -verify %s |
Ted Kremenek | 9b3d3a9 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 2 | |
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 3 | int f1(float x, float y) { |
Ted Kremenek | 9b3d3a9 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 4 | return x == y; // expected-warning {{comparing floating point with ==}} |
5 | } | ||||
6 | |||||
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 7 | int f2(float x, float y) { |
Ted Kremenek | 9b3d3a9 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 8 | return x != y; // expected-warning {{comparing floating point with ==}} |
Ted Kremenek | 9f3d942 | 2007-09-26 20:14:22 +0000 | [diff] [blame] | 9 | } |
Ted Kremenek | 6a26155 | 2007-10-29 16:40:01 +0000 | [diff] [blame] | 10 | |
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 11 | int f3(float x) { |
Ted Kremenek | 6a26155 | 2007-10-29 16:40:01 +0000 | [diff] [blame] | 12 | return x == x; // no-warning |
13 | } | ||||
Ted Kremenek | c8f488d | 2007-11-13 19:17:00 +0000 | [diff] [blame] | 14 | |
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 15 | int f4(float x) { |
Ted Kremenek | b594a40 | 2007-11-29 01:03:21 +0000 | [diff] [blame] | 16 | return x == 0.0; // no-warning {{comparing}} |
Ted Kremenek | c8f488d | 2007-11-13 19:17:00 +0000 | [diff] [blame] | 17 | } |
18 | |||||
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 19 | int f5(float x) { |
Ted Kremenek | c8f488d | 2007-11-13 19:17:00 +0000 | [diff] [blame] | 20 | return x == __builtin_inf(); // no-warning |
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 21 | } |
22 | |||||
Ted Kremenek | 9e7f0ec | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 23 | int f7(float x) { |
24 | return x == 3.14159; // expected-warning {{comparing}} | ||||
25 | } |