[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / clang / test / CodeGen / ms_struct-bitfield.c
blob37b0245e57c453e5e0c698fd601963cc7c706bdc
1 // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin9 %s | FileCheck %s
2 // RUN: %clang_cc1 -emit-llvm -o - -triple thumbv7-apple-ios -target-abi apcs-gnu %s | FileCheck %s -check-prefix=CHECK-ARM
4 // Note that we're declaring global variables with these types,
5 // triggering both Sema and IRGen struct layout.
7 #define ATTR __attribute__((__ms_struct__))
9 struct
11 char foo;
12 long : 0;
13 char bar;
14 } ATTR t1;
15 int s1 = sizeof(t1);
16 // CHECK: @s1 ={{.*}} global i32 2
17 // CHECK-ARM: @s1 ={{.*}} global i32 2
19 struct
21 char foo;
22 long : 0;
23 char : 0;
24 int : 0;
25 char bar;
26 } ATTR t2;
27 int s2 = sizeof(t2);
28 // CHECK: @s2 ={{.*}} global i32 2
29 // CHECK-ARM: @s2 ={{.*}} global i32 2
31 struct
33 char foo;
34 long : 0;
35 char : 0;
36 int : 0;
37 char bar;
38 long : 0;
39 char : 0;
40 } ATTR t3;
41 int s3 = sizeof(t3);
42 // CHECK: @s3 ={{.*}} global i32 2
43 // CHECK-ARM: @s3 ={{.*}} global i32 2
45 struct
47 long : 0;
48 char bar;
49 } ATTR t4;
50 int s4 = sizeof(t4);
51 // CHECK: @s4 ={{.*}} global i32 1
52 // CHECK-ARM: @s4 ={{.*}} global i32 1
54 struct
56 long : 0;
57 long : 0;
58 char : 0;
59 char bar;
60 } ATTR t5;
61 int s5 = sizeof(t5);
62 // CHECK: @s5 ={{.*}} global i32 1
63 // CHECK-ARM: @s5 ={{.*}} global i32 1
65 struct
67 long : 0;
68 long : 0;
69 char : 0;
70 char bar;
71 } ATTR t6;
72 int s6 = sizeof(t6);
73 // CHECK: @s6 ={{.*}} global i32 1
74 // CHECK-ARM: @s6 ={{.*}} global i32 1
76 struct
78 char foo;
79 long : 0;
80 int : 0;
81 char bar;
82 char bar1;
83 long : 0;
84 char bar2;
85 char bar3;
86 char : 0;
87 char bar4;
88 char bar5;
89 char : 0;
90 char bar6;
91 char bar7;
92 } ATTR t7;
93 int s7 = sizeof(t7);
94 // CHECK: @s7 ={{.*}} global i32 9
95 // CHECK-ARM: @s7 ={{.*}} global i32 9
97 struct
99 long : 0;
100 long : 0;
101 char : 0;
102 } ATTR t8;
103 int s8 = sizeof(t8);
104 // CHECK: @s8 ={{.*}} global i32 0
105 // CHECK-ARM: @s8 ={{.*}} global i32 0
107 struct
109 char foo;
110 long : 0;
111 int : 0;
112 char bar;
113 char bar1;
114 long : 0;
115 char bar2;
116 char bar3;
117 char : 0;
118 char bar4;
119 char bar5;
120 char : 0;
121 char bar6;
122 char bar7;
123 int i1;
124 char : 0;
125 long : 0;
126 char :4;
127 char bar8;
128 char : 0;
129 char bar9;
130 char bar10;
131 int i2;
132 char : 0;
133 long : 0;
134 char :4;
135 } ATTR t9;
136 int s9 = sizeof(t9);
137 // CHECK: @s9 ={{.*}} global i32 28
138 // CHECK-ARM: @s9 ={{.*}} global i32 28
140 struct
142 char foo: 8;
143 long : 0;
144 char bar;
145 } ATTR t10;
146 int s10 = sizeof(t10);
147 // CHECK: @s10 ={{.*}} global i32 16
148 // CHECK-ARM: @s10 ={{.*}} global i32 8
150 // ensure that ms_structs work correctly on a !useBitFieldTypeAlignment() target
151 struct {
152 unsigned int a : 31;
153 unsigned int b : 2;
154 unsigned int c;
155 } ATTR t11;
156 int s11 = sizeof(t11);
157 // CHECK: @s11 ={{.*}} global i32 12
158 // CHECK-ARM: @s11 ={{.*}} global i32 12
160 struct {
161 unsigned char a : 3;
162 unsigned char b : 4;
163 unsigned short c : 6;
164 } ATTR t12;
165 int s12 = sizeof(t12);
166 // CHECK: @s12 ={{.*}} global i32 4
167 // CHECK-ARM: @s12 ={{.*}} global i32 4
169 struct {
170 unsigned char a : 3;
171 unsigned char b : 4;
172 __attribute__((packed)) unsigned short c : 6;
173 } ATTR t13;
174 int s13 = sizeof(t13);
175 // CHECK: @s13 ={{.*}} global i32 4
176 // CHECK-ARM: @s13 ={{.*}} global i32 4