2010-01-18 16:54:31 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-experimental-checks -checker-cfref -analyzer-store=region -verify %s
|
|
|
|
|
|
|
|
typedef __typeof(sizeof(int)) size_t;
|
|
|
|
void *malloc(size_t);
|
2008-11-24 10:19:49 +08:00
|
|
|
|
|
|
|
char f1() {
|
|
|
|
char* s = "abcd";
|
2009-01-23 04:36:33 +08:00
|
|
|
char c = s[4]; // no-warning
|
2009-11-11 20:33:27 +08:00
|
|
|
return s[5] + c; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
|
2008-11-24 10:19:49 +08:00
|
|
|
}
|
2010-01-18 16:54:31 +08:00
|
|
|
|
|
|
|
void f2() {
|
|
|
|
int *p = malloc(12);
|
|
|
|
p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
|
|
|
|
}
|