blob: 45325e92f376c8ffa6b8b7495c80116789f27c28 [file] [log] [blame]
Ted Kremenek565e4652010-02-05 02:06:54 +00001// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-experimental-checks -analyzer-check-objc-mem -analyzer-store=region -verify %s
Zhongxing Xu3ed04d32010-01-18 08:54:31 +00002
3typedef __typeof(sizeof(int)) size_t;
4void *malloc(size_t);
Zhongxing Xu20f01782008-11-24 02:19:49 +00005
6char f1() {
7 char* s = "abcd";
Ted Kremenekf9e96842009-01-22 20:36:33 +00008 char c = s[4]; // no-warning
Zhongxing Xu58e689f2009-11-11 12:33:27 +00009 return s[5] + c; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
Zhongxing Xu20f01782008-11-24 02:19:49 +000010}
Zhongxing Xu3ed04d32010-01-18 08:54:31 +000011
12void f2() {
13 int *p = malloc(12);
14 p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
15}