Allow resolving headers from a PCH even after headers+PCH were moved to another path.
[clang.git] / test / Sema / bitfield-layout.c
blob2655fc70cd4c427bde64cf2062014bb79c1025b1
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
3 #define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == size ? 1 : -1];
4 #define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) == size ? 1 : -1];
6 // Zero-width bit-fields
7 struct a {char x; int : 0; char y;};
8 CHECK_SIZE(struct, a, 5)
9 CHECK_ALIGN(struct, a, 1)
11 union b {char x; int : 0; char y;};
12 CHECK_SIZE(union, b, 1)
13 CHECK_ALIGN(union, b, 1)
15 // Unnamed bit-field align
16 struct c {char x; int : 20;};
17 CHECK_SIZE(struct, c, 4)
18 CHECK_ALIGN(struct, c, 1)
20 union d {char x; int : 20;};
21 CHECK_SIZE(union, d, 3)
22 CHECK_ALIGN(union, d, 1)
24 // Bit-field packing
25 struct __attribute__((packed)) e {int x : 4, y : 30, z : 30;};
26 CHECK_SIZE(struct, e, 8)
27 CHECK_ALIGN(struct, e, 1)
29 // Alignment on bit-fields
30 struct f {__attribute((aligned(8))) int x : 30, y : 30, z : 30;};
31 CHECK_SIZE(struct, f, 24)
32 CHECK_ALIGN(struct, f, 8)
34 // Large structure (overflows i32, in bits).
35 struct s0 {
36 char a[0x32100000];
37 int x:30, y:30;
40 CHECK_SIZE(struct, s0, 0x32100008)
41 CHECK_ALIGN(struct, s0, 4)