1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // Test case from PR10615 4*f4a2713aSLionel Sambuc struct ext2_super_block{ 5*f4a2713aSLionel Sambuc unsigned char s_uuid[8]; // expected-note {{declared here}} 6*f4a2713aSLionel Sambuc }; ext2_statfs(struct ext2_super_block * es,int a)7*f4a2713aSLionel Sambucvoid* ext2_statfs (struct ext2_super_block *es,int a) 8*f4a2713aSLionel Sambuc { 9*f4a2713aSLionel Sambuc return (void *)es->s_uuid + sizeof(int); // no-warning 10*f4a2713aSLionel Sambuc } broken(struct ext2_super_block * es,int a)11*f4a2713aSLionel Sambucvoid* broken (struct ext2_super_block *es,int a) 12*f4a2713aSLionel Sambuc { 13*f4a2713aSLionel Sambuc return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}} 14*f4a2713aSLionel Sambuc } 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc // Test case reduced from PR11594 17*f4a2713aSLionel Sambuc struct S { int n; }; pr11594(struct S * s)18*f4a2713aSLionel Sambucvoid pr11594(struct S *s) { 19*f4a2713aSLionel Sambuc int a[10]; 20*f4a2713aSLionel Sambuc int *p = a - s->n; 21*f4a2713aSLionel Sambuc } 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc // Test case reduced from <rdar://problem/11387038>. This resulted in 24*f4a2713aSLionel Sambuc // an assertion failure because of the typedef instead of an explicit 25*f4a2713aSLionel Sambuc // constant array type. 26*f4a2713aSLionel Sambuc struct RDar11387038 {}; 27*f4a2713aSLionel Sambuc typedef struct RDar11387038 RDar11387038Array[1]; 28*f4a2713aSLionel Sambuc struct RDar11387038_Table { 29*f4a2713aSLionel Sambuc RDar11387038Array z; 30*f4a2713aSLionel Sambuc }; 31*f4a2713aSLionel Sambuc typedef struct RDar11387038_Table * TPtr; 32*f4a2713aSLionel Sambuc typedef TPtr *TabHandle; 33*f4a2713aSLionel Sambuc struct RDar11387038_B { TabHandle x; }; 34*f4a2713aSLionel Sambuc typedef struct RDar11387038_B RDar11387038_B; 35*f4a2713aSLionel Sambuc radar11387038()36*f4a2713aSLionel Sambucvoid radar11387038() { 37*f4a2713aSLionel Sambuc RDar11387038_B *pRDar11387038_B; 38*f4a2713aSLionel Sambuc struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4]; 39*f4a2713aSLionel Sambuc } 40