Ted Kremenek | 565e465 | 2010-02-05 02:06:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s |
Zhongxing Xu | bc37b8d | 2010-01-09 09:16:47 +0000 | [diff] [blame] | 2 | |
| 3 | void f1() { |
| 4 | int const &i = 3; |
| 5 | int b = i; |
Zhongxing Xu | 3cd8bd4 | 2010-01-10 02:52:56 +0000 | [diff] [blame] | 6 | |
| 7 | int *p = 0; |
| 8 | |
| 9 | if (b != 3) |
| 10 | *p = 1; // no-warning |
Zhongxing Xu | bc37b8d | 2010-01-09 09:16:47 +0000 | [diff] [blame] | 11 | } |
Zhongxing Xu | fc61d94 | 2010-06-03 06:23:18 +0000 | [diff] [blame] | 12 | |
| 13 | char* ptr(); |
| 14 | char& ref(); |
| 15 | |
| 16 | // These next two tests just shouldn't crash. |
| 17 | char t1 () { |
| 18 | ref() = 'c'; |
| 19 | return '0'; |
| 20 | } |
| 21 | |
| 22 | // just a sanity test, the same behavior as t1() |
| 23 | char t2 () { |
| 24 | *ptr() = 'c'; |
| 25 | return '0'; |
| 26 | } |