Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s |
Ted Kremenek | 5ccf0d8 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 2 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 3 | int f1(float x, float y) { |
Ted Kremenek | 5ccf0d8 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 4 | return x == y; // expected-warning {{comparing floating point with ==}} |
| 5 | } |
| 6 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 7 | int f2(float x, float y) { |
Ted Kremenek | 5ccf0d8 | 2007-08-29 18:06:12 +0000 | [diff] [blame] | 8 | return x != y; // expected-warning {{comparing floating point with ==}} |
Ted Kremenek | 0883fd5 | 2007-09-26 20:14:22 +0000 | [diff] [blame] | 9 | } |
Ted Kremenek | d4ecc6d | 2007-10-29 16:40:01 +0000 | [diff] [blame] | 10 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 11 | int f3(float x) { |
Ted Kremenek | d4ecc6d | 2007-10-29 16:40:01 +0000 | [diff] [blame] | 12 | return x == x; // no-warning |
| 13 | } |
Ted Kremenek | b83f182 | 2007-11-13 19:17:00 +0000 | [diff] [blame] | 14 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 15 | int f4(float x) { |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 16 | return x == 0.0; // no-warning {{comparing}} |
Ted Kremenek | b83f182 | 2007-11-13 19:17:00 +0000 | [diff] [blame] | 17 | } |
| 18 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 19 | int f5(float x) { |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 20 | return x == __builtin_inf(); // no-warning |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Ted Kremenek | 0865d8a | 2007-11-29 01:00:11 +0000 | [diff] [blame] | 23 | int f7(float x) { |
| 24 | return x == 3.14159; // expected-warning {{comparing}} |
| 25 | } |