xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/bitfield-layout.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP64 %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix CHECK-LP32 %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
5*f4a2713aSLionel Sambuc union Test1 {
6*f4a2713aSLionel Sambuc   int a;
7*f4a2713aSLionel Sambuc   int b: 39;
8*f4a2713aSLionel Sambuc } t1;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // CHECK-LP64: %union.Test2 = type { i8 }
11*f4a2713aSLionel Sambuc union Test2 {
12*f4a2713aSLionel Sambuc   int : 6;
13*f4a2713aSLionel Sambuc } t2;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // CHECK-LP64: %union.Test3 = type { [2 x i8] }
16*f4a2713aSLionel Sambuc union Test3 {
17*f4a2713aSLionel Sambuc   int : 9;
18*f4a2713aSLionel Sambuc } t3;
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc #define CHECK(x) if (!(x)) return __LINE__
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc int f() {
24*f4a2713aSLionel Sambuc   struct {
25*f4a2713aSLionel Sambuc     int a;
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc     unsigned long long b : 65;
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc     int c;
30*f4a2713aSLionel Sambuc   } c;
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc   c.a = 0;
33*f4a2713aSLionel Sambuc   c.b = (unsigned long long)-1;
34*f4a2713aSLionel Sambuc   c.c = 0;
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc   CHECK(c.a == 0);
37*f4a2713aSLionel Sambuc   CHECK(c.b == (unsigned long long)-1);
38*f4a2713aSLionel Sambuc   CHECK(c.c == 0);
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc // CHECK-LP64: ret i32 0
41*f4a2713aSLionel Sambuc // CHECK-LP32: ret i32 0
42*f4a2713aSLionel Sambuc   return 0;
43*f4a2713aSLionel Sambuc }
44