array-struct.c revision 82bd99f4db2454cc6e1b7bfaac6db25cb3444ddc
1// RUN: clang -checker-simple -verify %s 2// DISABLED: clang -checker-simple -analyzer-store-region -verify %s 3 4struct s { 5 int data; 6 int data_array[10]; 7}; 8 9typedef struct { 10 int data; 11} STYPE; 12 13void g1(struct s* p); 14 15void f(void) { 16 int a[10]; 17 int (*p)[10]; 18 p = &a; 19 (*p)[3] = 1; 20 21 struct s d; 22 struct s *q; 23 q = &d; 24 q->data = 3; 25 d.data_array[9] = 17; 26} 27 28void f2() { 29 char *p = "/usr/local"; 30 char (*q)[4]; 31 q = &"abc"; 32} 33 34void f3() { 35 STYPE s; 36} 37 38void f4() { 39 int a[] = { 1, 2, 3}; 40 int b[3] = { 1, 2 }; 41} 42 43void f5() { 44 struct s data; 45 g1(&data); 46} 47 48void f6() { 49 char *p; 50 p = __builtin_alloca(10); 51 p[1] = 'a'; 52} 53 54struct s2; 55 56void g2(struct s2 *p); 57 58void f7() { 59 struct s2 *p = __builtin_alloca(10); 60 g2(p); 61} 62 63void f8() { 64 int a[10]; 65 a[sizeof(a) - 1] = 1; 66} 67