xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/pragma-pack-1.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // PR4610
4f4a2713aSLionel Sambuc #pragma pack(4)
5f4a2713aSLionel Sambuc struct ref {
6f4a2713aSLionel Sambuc         struct ref *next;
7f4a2713aSLionel Sambuc } refs;
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc // PR13580
10f4a2713aSLionel Sambuc struct S
11f4a2713aSLionel Sambuc {
12f4a2713aSLionel Sambuc   char a[3];
13f4a2713aSLionel Sambuc #pragma pack(1)
14f4a2713aSLionel Sambuc   struct T
15f4a2713aSLionel Sambuc   {
16f4a2713aSLionel Sambuc     char b;
17f4a2713aSLionel Sambuc     int c;
18f4a2713aSLionel Sambuc   } d;
19f4a2713aSLionel Sambuc #pragma pack()
20f4a2713aSLionel Sambuc   struct T2
21f4a2713aSLionel Sambuc   {
22f4a2713aSLionel Sambuc     char b;
23f4a2713aSLionel Sambuc     int c;
24f4a2713aSLionel Sambuc   } d2;
25f4a2713aSLionel Sambuc } ss;
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc struct S3
28f4a2713aSLionel Sambuc {
29f4a2713aSLionel Sambuc   char a[3];
30f4a2713aSLionel Sambuc #pragma pack(push, 2)
31f4a2713aSLionel Sambuc   struct T3
32f4a2713aSLionel Sambuc   {
33f4a2713aSLionel Sambuc     char b;
34f4a2713aSLionel Sambuc     int c;
35f4a2713aSLionel Sambuc   } d;
36f4a2713aSLionel Sambuc #pragma pack(pop)
37f4a2713aSLionel Sambuc   struct T32
38f4a2713aSLionel Sambuc   {
39f4a2713aSLionel Sambuc     char b;
40f4a2713aSLionel Sambuc     int c;
41f4a2713aSLionel Sambuc   } e;
42f4a2713aSLionel Sambuc } s3;
43f4a2713aSLionel Sambuc 
44f4a2713aSLionel Sambuc struct S4
45f4a2713aSLionel Sambuc {
46f4a2713aSLionel Sambuc   char a[3];
47f4a2713aSLionel Sambuc #pragma align=packed
48f4a2713aSLionel Sambuc   struct T4
49f4a2713aSLionel Sambuc   {
50f4a2713aSLionel Sambuc     char b;
51f4a2713aSLionel Sambuc     int c;
52f4a2713aSLionel Sambuc   } d;
53f4a2713aSLionel Sambuc   int e;
54f4a2713aSLionel Sambuc } s4;
55f4a2713aSLionel Sambuc 
56*0a6a1f1dSLionel Sambuc // CHECK: [[struct_ref:%[a-zA-Z0-9_.]+]] = type { [[struct_ref]]* }
57f4a2713aSLionel Sambuc // CHECK: [[struct_S:%[a-zA-Z0-9_.]+]] = type { [3 x i8], [[struct_T:%[a-zA-Z0-9_.]+]], [[struct_T2:%[a-zA-Z0-9_.]+]] }
58f4a2713aSLionel Sambuc // CHECK: [[struct_T]] = type <{ i8, i32 }>
59f4a2713aSLionel Sambuc // CHECK: [[struct_T2]] = type { i8, i32 }
60f4a2713aSLionel Sambuc 
61*0a6a1f1dSLionel Sambuc // CHECK: %struct.S3 = type { [3 x i8], i8, %struct.T3, %struct.T32 }
62f4a2713aSLionel Sambuc // CHECK: %struct.T3 = type <{ i8, i8, i32 }>
63f4a2713aSLionel Sambuc // CHECK: %struct.T32 = type { i8, i32 }
64f4a2713aSLionel Sambuc // CHECK: %struct.S4 = type { [3 x i8], %struct.T4, i32 }
65f4a2713aSLionel Sambuc // CHECK: %struct.T4 = type <{ i8, i32 }>
66f4a2713aSLionel Sambuc 
67f4a2713aSLionel Sambuc // CHECK: @refs = common global [[struct_ref]]
68f4a2713aSLionel Sambuc // CHECK: @ss = common global [[struct_S]]
69