Ted Kremenek | c5e43c1 | 2011-03-17 05:29:57 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wconditional-uninitialized -fsyntax-only %s -verify |
| 2 | |
| 3 | class Foo { |
| 4 | public: |
| 5 | Foo(); |
| 6 | ~Foo(); |
| 7 | operator bool(); |
| 8 | }; |
| 9 | |
| 10 | int bar(); |
| 11 | int baz(); |
| 12 | int init(double *); |
| 13 | |
| 14 | // This case flags a false positive under -Wconditional-uninitialized because |
| 15 | // the destructor in Foo fouls about the minor bit of path-sensitivity in |
| 16 | // -Wuninitialized. |
| 17 | double test() { |
David Blaikie | 4f4f349 | 2011-09-10 05:35:08 +0000 | [diff] [blame] | 18 | double x; // expected-note{{initialize the variable 'x' to silence this warning}} |
Ted Kremenek | 53b24eb | 2011-03-17 05:34:58 +0000 | [diff] [blame] | 19 | if (bar() || baz() || Foo() || init(&x)) |
| 20 | return 1.0; |
| 21 | |
Chandler Carruth | 584b9d6 | 2011-04-08 06:47:15 +0000 | [diff] [blame] | 22 | return x; // expected-warning {{variable 'x' may be uninitialized when used here}} |
Ted Kremenek | c5e43c1 | 2011-03-17 05:29:57 +0000 | [diff] [blame] | 23 | } |