Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // Contributed by Dodji Seketeli <dodji@redhat.com> | |
2 // Origin PR c++/38699 | |
3 // { dg-options "-Warray-bounds" } | |
4 // { dg-do compile } | |
5 | |
6 struct A | |
7 { | |
8 const char *p; | |
9 }; | |
10 | |
11 struct B | |
12 { | |
13 char p[10]; | |
14 struct A a; | |
15 }; | |
16 | |
17 void | |
18 f0 () | |
19 { | |
20 __builtin_offsetof(struct A, p); // OK | |
21 __builtin_offsetof(struct A, p[0]); // { dg-error "non constant address" } | |
22 __builtin_offsetof(struct B, p[0]); // OK | |
23 __builtin_offsetof(struct B, p[9]); // OK | |
24 __builtin_offsetof(struct B, p[10]); // OK | |
25 __builtin_offsetof(struct B, p[11]); // { dg-warning "greater than size" } | |
26 __builtin_offsetof(struct B, a.p); // OK | |
27 __builtin_offsetof(struct B, p[0]); // OK | |
28 __builtin_offsetof(struct B, a.p[0]); // { dg-error "non constant address" } | |
29 } |