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