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