1 // RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
3 typedef __typeof(sizeof(int)) size_t;
5 void *calloc(size_t, size_t);
9 char c = s[4]; // no-warning
10 return s[5] + c; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
15 p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
27 struct three_words a, *p;
29 p[0] = a; // no-warning
30 p[1] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
35 struct three_words a, *p = (struct three_words *)&c;
36 p[0] = a; // no-warning
37 p[1] = a; // no-warning
38 p[2] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
42 char *p = calloc(2,2);
43 p[3] = '.'; // no-warning
44 p[4] = '!'; // expected-warning{{out-of-bound}}
50 b[1] = 3; // expected-warning{{out-of-bound}}
55 a.c[3] = 1; // expected-warning{{out-of-bound}}
61 x[4] = 4; // no-warning
62 x[5] = 5; // expected-warning{{out-of-bound}}
66 void alloca_region(int a) {
68 char *x = __builtin_alloca(a);
69 x[4] = 4; // no-warning
70 x[5] = 5; // expected-warning{{out-of-bound}}
74 int symbolic_index(int a) {
77 return x[a]; // expected-warning{{out-of-bound}}
82 int symbolic_index2(int a) {
85 return x[a]; // expected-warning{{out-of-bound}}