Ted Kremenek | 565e465 | 2010-02-05 02:06:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=basic -verify %s |
| 2 | // RUN: %clang_cc1 -analyzer-check-objc-mem -analyze -analyzer-experimental-internal-checks -analyzer-store=region -verify %s |
Ted Kremenek | 2f08991 | 2009-07-10 21:48:10 +0000 | [diff] [blame] | 3 | |
| 4 | //===----------------------------------------------------------------------===// |
| 5 | // This file tests cases where we should not flag out-of-bounds warnings. |
| 6 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0b9ad89 | 2009-05-04 14:31:19 +0000 | [diff] [blame] | 7 | |
Ted Kremenek | 20bd746 | 2009-05-04 07:04:36 +0000 | [diff] [blame] | 8 | void f() { |
| 9 | long x = 0; |
| 10 | char *y = (char*) &x; |
| 11 | char c = y[0] + y[1] + y[2]; // no-warning |
Zhongxing Xu | 9618b85 | 2010-04-01 08:20:27 +0000 | [diff] [blame] | 12 | short *z = (short*) &x; |
| 13 | short s = z[0] + z[1]; // no-warning |
Ted Kremenek | 20bd746 | 2009-05-04 07:04:36 +0000 | [diff] [blame] | 14 | } |
Jordy Rose | 4d912b2 | 2010-06-25 23:23:04 +0000 | [diff] [blame] | 15 | |
| 16 | void g() { |
| 17 | int a[2]; |
| 18 | char *b = (char*)a; |
| 19 | b[3] = 'c'; // no-warning |
| 20 | } |