Ted Kremenek | 908c09f | 2011-03-15 05:22:33 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fblocks %s -verify |
Ted Kremenek | 1ea800c | 2011-01-27 02:01:31 +0000 | [diff] [blame] | 2 | |
| 3 | // Duplicated from uninit-variables.c. |
| 4 | // Test just to ensure the analysis is working. |
| 5 | int test1() { |
David Blaikie | 4f4f349 | 2011-09-10 05:35:08 +0000 | [diff] [blame] | 6 | int x; // expected-note{{initialize the variable 'x' to silence this warning}} |
Chandler Carruth | f04eb2d | 2011-04-08 06:33:38 +0000 | [diff] [blame] | 7 | return x; // expected-warning{{variable 'x' is uninitialized when used here}} |
Ted Kremenek | 1ea800c | 2011-01-27 02:01:31 +0000 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | // Test ObjC fast enumeration. |
| 11 | void test2() { |
| 12 | id collection = 0; |
| 13 | for (id obj in collection) { |
| 14 | if (0 == obj) // no-warning |
| 15 | break; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | void test3() { |
| 20 | id collection = 0; |
| 21 | id obj; |
| 22 | for (obj in collection) { // no-warning |
| 23 | if (0 == obj) // no-warning |
| 24 | break; |
| 25 | } |
| 26 | } |
| 27 | |