Zhongxing Xu | 1c625f2 | 2010-05-06 03:38:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s |
| 2 | |
Zhongxing Xu | 06079d1 | 2010-02-27 02:44:37 +0000 | [diff] [blame] | 3 | int f1() { |
| 4 | int y = 1; |
| 5 | y++; |
| 6 | return y; |
| 7 | } |
| 8 | |
| 9 | void f2() { |
| 10 | int x = 1; |
| 11 | x = f1(); |
| 12 | if (x == 1) { |
| 13 | int *p = 0; |
| 14 | *p = 3; // no-warning |
| 15 | } |
| 16 | if (x == 2) { |
| 17 | int *p = 0; |
Ted Kremenek | 452b84d | 2010-03-23 01:11:38 +0000 | [diff] [blame] | 18 | *p = 3; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} |
Zhongxing Xu | 06079d1 | 2010-02-27 02:44:37 +0000 | [diff] [blame] | 19 | } |
| 20 | } |