]>
Commit | Line | Data |
---|---|---|
5fee5ec3 IB |
1 | /* |
2 | REQUIRED_ARGS: -HC -c -o- | |
3 | PERMUTE_ARGS: | |
4 | TEST_OUTPUT: | |
5 | --- | |
6 | // Automatically generated by Digital Mars D Compiler | |
7 | ||
8 | #pragma once | |
9 | ||
10 | #include <assert.h> | |
11 | #include <stddef.h> | |
12 | #include <stdint.h> | |
13 | #include <math.h> | |
14 | ||
15 | #ifdef CUSTOM_D_ARRAY_TYPE | |
16 | #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE | |
17 | #else | |
18 | /// Represents a D [] array | |
19 | template<typename T> | |
20 | struct _d_dynamicArray final | |
21 | { | |
22 | size_t length; | |
23 | T *ptr; | |
24 | ||
25 | _d_dynamicArray() : length(0), ptr(NULL) { } | |
26 | ||
27 | _d_dynamicArray(size_t length_in, T *ptr_in) | |
28 | : length(length_in), ptr(ptr_in) { } | |
29 | ||
30 | T& operator[](const size_t idx) { | |
31 | assert(idx < length); | |
32 | return ptr[idx]; | |
33 | } | |
34 | ||
35 | const T& operator[](const size_t idx) const { | |
36 | assert(idx < length); | |
37 | return ptr[idx]; | |
38 | } | |
39 | }; | |
40 | #endif | |
41 | ||
42 | struct S final | |
43 | { | |
44 | int8_t a; | |
45 | int32_t b; | |
46 | int64_t c; | |
47 | _d_dynamicArray< int32_t > arr; | |
48 | S() : | |
49 | a(), | |
50 | b(), | |
51 | c(), | |
52 | arr() | |
53 | { | |
54 | } | |
55 | S(int8_t a, int32_t b = 0, int64_t c = 0LL, _d_dynamicArray< int32_t > arr = {}) : | |
56 | a(a), | |
57 | b(b), | |
58 | c(c), | |
59 | arr(arr) | |
60 | {} | |
61 | }; | |
62 | ||
63 | struct S2 final | |
64 | { | |
65 | int32_t a; | |
66 | int32_t b; | |
67 | int64_t c; | |
68 | S d; | |
69 | S2(int32_t a); | |
70 | S2(char ) = delete; | |
71 | S2() : | |
72 | a(42), | |
73 | b(), | |
74 | c() | |
75 | { | |
76 | } | |
77 | }; | |
78 | ||
79 | struct S3 final | |
80 | { | |
81 | int32_t a; | |
82 | int32_t b; | |
83 | int64_t c; | |
84 | extern "C" S3(int32_t a); | |
85 | S3() : | |
86 | a(42), | |
87 | b(), | |
88 | c() | |
89 | { | |
90 | } | |
91 | }; | |
92 | ||
93 | struct S4 final | |
94 | { | |
95 | int32_t a; | |
96 | int64_t b; | |
97 | int32_t c; | |
98 | int8_t d; | |
99 | S4() : | |
100 | a(), | |
101 | b(), | |
102 | c(), | |
103 | d() | |
104 | { | |
105 | } | |
106 | S4(int32_t a, int64_t b = 0LL, int32_t c = 0, int8_t d = 0) : | |
107 | a(a), | |
108 | b(b), | |
109 | c(c), | |
110 | d(d) | |
111 | {} | |
112 | }; | |
113 | ||
114 | #pragma pack(push, 1) | |
115 | struct Aligned final | |
116 | { | |
117 | int8_t a; | |
118 | int32_t b; | |
119 | int64_t c; | |
120 | Aligned(int32_t a); | |
121 | Aligned() : | |
122 | a(), | |
123 | b(), | |
124 | c() | |
125 | { | |
126 | } | |
127 | }; | |
128 | #pragma pack(pop) | |
129 | ||
130 | struct Null final | |
131 | { | |
132 | void* field; | |
133 | Null() : | |
134 | field(nullptr) | |
135 | { | |
136 | } | |
137 | Null(void* field) : | |
138 | field(field) | |
139 | {} | |
140 | }; | |
141 | ||
142 | struct A final | |
143 | { | |
144 | int32_t a; | |
145 | S s; | |
146 | extern "C" void bar(); | |
147 | void baz(int32_t x = 42); | |
148 | struct | |
149 | { | |
150 | int32_t x; | |
151 | int32_t y; | |
152 | }; | |
153 | union | |
154 | { | |
155 | int32_t u1; | |
156 | char u2[4$?:32=u|64=LLU$]; | |
157 | }; | |
158 | struct Inner final | |
159 | { | |
160 | int32_t x; | |
161 | Inner() : | |
162 | x() | |
163 | { | |
164 | } | |
165 | Inner(int32_t x) : | |
166 | x(x) | |
167 | {} | |
168 | }; | |
169 | ||
170 | typedef Inner I; | |
171 | class C; | |
172 | ||
173 | A() : | |
174 | a(), | |
175 | s() | |
176 | { | |
177 | } | |
178 | A(int32_t a, S s = S(0, 0, 0LL, {})) : | |
179 | a(a), | |
180 | s(s) | |
181 | {} | |
182 | }; | |
183 | ||
184 | union U | |
185 | { | |
186 | int32_t i; | |
187 | char c; | |
188 | }; | |
189 | --- | |
190 | */ | |
191 | ||
192 | /* | |
193 | StructDeclaration has the following issues: | |
194 | * align different than 1 does nothing; we should support align(n), where `n` in [1, 2, 4, 8, 16] | |
195 | * align(n): inside struct definition doesn’t add alignment, but breaks generation of default ctors | |
196 | */ | |
197 | ||
198 | extern (C++) struct S | |
199 | { | |
200 | byte a; | |
201 | int b; | |
202 | long c; | |
203 | int[] arr; | |
204 | } | |
205 | ||
206 | extern (C++) struct S2 | |
207 | { | |
208 | int a = 42; | |
209 | int b; | |
210 | long c; | |
211 | S d = void; | |
212 | ||
213 | this(int a) {} | |
214 | extern(D) this(int, int, long) {} | |
215 | @disable this(char); | |
216 | } | |
217 | ||
218 | extern (C) struct S3 | |
219 | { | |
220 | int a = 42; | |
221 | int b; | |
222 | long c; | |
223 | ||
224 | this(int a) {} | |
225 | } | |
226 | ||
227 | extern (C) struct S4 | |
228 | { | |
229 | int a; | |
230 | long b; | |
231 | int c; | |
232 | byte d; | |
233 | } | |
234 | ||
235 | extern (C++) align(1) struct Aligned | |
236 | { | |
237 | //align(1): | |
238 | byte a; | |
239 | int b; | |
240 | long c; | |
241 | ||
242 | this(int a) {} | |
243 | } | |
244 | ||
245 | extern (C++) struct Null | |
246 | { | |
247 | void* field = null; | |
248 | } | |
249 | ||
250 | extern (C++) struct A | |
251 | { | |
252 | int a; | |
253 | S s; | |
254 | ||
255 | extern (D) void foo(); | |
256 | extern (C) void bar() {} | |
257 | extern (C++) void baz(int x = 42) {} | |
258 | ||
259 | struct | |
260 | { | |
261 | int x; | |
262 | int y; | |
263 | } | |
264 | ||
265 | union | |
266 | { | |
267 | int u1; | |
268 | char[4] u2; | |
269 | } | |
270 | ||
271 | struct Inner | |
272 | { | |
273 | int x; | |
274 | } | |
275 | ||
276 | alias I = Inner; | |
277 | ||
278 | extern(C++) class C; | |
279 | ||
280 | } | |
281 | ||
282 | extern(C++) union U | |
283 | { | |
284 | int i; | |
285 | char c; | |
286 | } |