OSDN Git Service

c4a0564b59961142146c5d44a299f30b114142f3
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / c99-flex-array-4.c
1 /* Test for flexible array members.  Test for agreement of offset and
2    structure size.  This is expected to fail, because of a possible
3    defect in the standard.  */
4 /* Origin: http://gcc.gnu.org/ml/gcc/2002-05/msg02844.html
5    from Tony Finch <dot@dotat.at>, adapted to a testcase by Joseph Myers
6    <jsm28@cam.ac.uk>.  See also WG14 reflector messages 9571-3.  */
7 /* { dg-do compile } */
8 /* -fpack-struct is necessary because the code below assumes the initial
9    packing is larger than 1, which cannot ge guaranteed for all targets. */
10 /* { dg-options "-std=iso9899:1999 -fpack-struct=8 -pedantic-errors" } */
11
12 #include <stddef.h>
13
14 struct foo {
15   int a;
16   short b;
17   char pad[];
18 };
19
20 struct bar {
21   int a;
22   short b;
23   char pad[1024];
24 };
25
26 char x[(sizeof(struct foo) == offsetof(struct foo, pad)) ? 1 : -1]; /* { dg-bogus "negative" "sizeof != offsetof" { xfail *-*-* } } */
27 char y[(offsetof(struct foo, pad) == offsetof(struct bar, pad)) ? 1 : -1];