annotate gcc/testsuite/c-c++-common/builtin-offsetof.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Contributed by Dodji Seketeli <dodji@redhat.com>
kono
parents:
diff changeset
2 // Origin PR c++/38699
kono
parents:
diff changeset
3 // { dg-options "-Warray-bounds" }
kono
parents:
diff changeset
4 // { dg-do compile }
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 struct A
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 const char *p;
kono
parents:
diff changeset
9 };
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 struct B
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 char p[10];
kono
parents:
diff changeset
14 struct A a;
kono
parents:
diff changeset
15 };
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 void
kono
parents:
diff changeset
18 f0 ()
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 __builtin_offsetof(struct A, p); // OK
kono
parents:
diff changeset
21 __builtin_offsetof(struct A, p[0]); // { dg-error "non constant address" }
kono
parents:
diff changeset
22 __builtin_offsetof(struct B, p[0]); // OK
kono
parents:
diff changeset
23 __builtin_offsetof(struct B, p[9]); // OK
kono
parents:
diff changeset
24 __builtin_offsetof(struct B, p[10]); // OK
kono
parents:
diff changeset
25 __builtin_offsetof(struct B, p[11]); // { dg-warning "greater than size" }
kono
parents:
diff changeset
26 __builtin_offsetof(struct B, a.p); // OK
kono
parents:
diff changeset
27 __builtin_offsetof(struct B, p[0]); // OK
kono
parents:
diff changeset
28 __builtin_offsetof(struct B, a.p[0]); // { dg-error "non constant address" }
kono
parents:
diff changeset
29 }