blob: 5f747fda8c89ff1323842c55a652087851019e41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
/*
REQUIRED_ARGS: -HC -c -o-
PERMUTE_ARGS:
TEST_OUTPUT:
---
// Automatically generated by Digital Mars D Compiler
#pragma once
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <math.h>
#ifdef CUSTOM_D_ARRAY_TYPE
#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
#else
/// Represents a D [] array
template<typename T>
struct _d_dynamicArray final
{
size_t length;
T *ptr;
_d_dynamicArray() : length(0), ptr(NULL) { }
_d_dynamicArray(size_t length_in, T *ptr_in)
: length(length_in), ptr(ptr_in) { }
T& operator[](const size_t idx) {
assert(idx < length);
return ptr[idx];
}
const T& operator[](const size_t idx) const {
assert(idx < length);
return ptr[idx];
}
};
#endif
typedef uint$?:32=32|64=64$_t size_t;
struct Outer final
{
int32_t a;
struct Member final
{
typedef int32_t Nested;
Member()
{
}
};
Outer() :
a()
{
}
Outer(int32_t a) :
a(a)
{}
};
enum : int32_t { SomeOtherLength = 1 };
struct ActualBuffer final
{
ActualBuffer()
{
}
};
template <typename T>
struct A final
{
// Ignoring var x alignment 0
T x;
// Ignoring var Enum alignment 0
enum : int32_t { Enum = 42 };
// Ignoring var GsharedNum alignment 0
static int32_t GsharedNum;
// Ignoring var MemNum alignment 0
const int32_t MemNum;
void foo();
A()
{
}
};
template <typename T>
struct NotInstantiated final
{
// Ignoring var noInit alignment 0
// Ignoring var missingSem alignment 0
NotInstantiated()
{
}
};
struct B final
{
A<int32_t > x;
B() :
x()
{
}
B(A<int32_t > x) :
x(x)
{}
};
template <typename T>
struct Foo final
{
// Ignoring var val alignment 0
T val;
Foo()
{
}
};
template <typename T>
struct Bar final
{
// Ignoring var v alignment 0
Foo<T > v;
Bar()
{
}
};
template <typename T>
struct Array final
{
typedef Array This;
typedef typeof(1 + 2) Int;
typedef typeof(T::a) IC;
Array(size_t dim);
~Array();
void get() const;
template <typename T>
bool opCast() const;
// Ignoring var i alignment 0
typename T::Member i;
// Ignoring var j alignment 0
typename Outer::Member::Nested j;
void visit(typename T::Member::Nested i);
Array()
{
}
};
template <typename T, typename U>
extern T foo(U u);
extern A<A<int32_t > > aaint;
template <typename T>
class Parent
{
// Ignoring var parentMember alignment 0
public:
T parentMember;
void parentFinal();
virtual void parentVirtual();
};
template <typename T>
class Child final : public Parent<T >
{
// Ignoring var childMember alignment 0
public:
T childMember;
void parentVirtual();
T childFinal();
};
extern void withDefTempl(A<int32_t > a = A<int32_t >(2, 13));
template <typename T>
extern void withDefTempl2(A<T > a = static_cast<A<T >>(A<T >(2)));
class ChildInt : public Parent<int32_t >
{
};
struct HasMixins final
{
void foo(int32_t t);
HasMixins()
{
}
};
template <typename T>
struct HasMixinsTemplate final
{
void foo(T t);
HasMixinsTemplate()
{
}
};
extern HasMixinsTemplate<bool > hmti;
template <typename T>
struct NotAA final
{
// Ignoring var length alignment 0
enum : int32_t { length = 12 };
// Ignoring var buffer alignment 0
T buffer[length];
// Ignoring var otherBuffer alignment 0
T otherBuffer[SomeOtherLength];
// Ignoring var calcBuffer alignment 0
T calcBuffer[foo(1)];
NotAA()
{
}
};
template <typename Buffer>
struct BufferTmpl final
{
// Ignoring var buffer alignment 0
Buffer buffer;
// Ignoring var buffer2 alignment 0
Buffer buffer2;
BufferTmpl()
{
}
};
struct ImportedBuffer final
{
typedef ActualBuffer Buffer;
ActualBuffer buffer2;
ImportedBuffer()
{
}
};
---
*/
extern (C++) struct A(T)
{
T x;
enum Enum = 42;
__gshared GsharedNum = 43;
immutable MemNum = 13;
void foo() {}
}
// Invalid declarations accepted because it's not instantiated
extern (C++) struct NotInstantiated(T)
{
enum T noInit;
enum missingSem = T.init;
}
extern (C++) struct B
{
A!int x;
}
// https://issues.dlang.org/show_bug.cgi?id=20604
extern(C++)
{
struct Foo (T)
{
T val;
}
struct Bar (T)
{
Foo!T v;
}
}
extern (C++) struct Array(T)
{
alias This = typeof(this);
alias Int = typeof(1 + 2);
alias IC = typeof(T.a);
this(size_t dim) pure nothrow {}
@disable this(this);
~this() {}
void get() const {}
bool opCast(T)() const pure nothrow @nogc @safe
if (is(T == bool))
{
return str.ptr !is null;
}
T.Member i;
Outer.Member.Nested j;
void visit(T.Member.Nested i) {}
}
struct Outer
{
int a;
static struct Member
{
alias Nested = int;
}
}
// alias AO = Array!Outer;
extern(C++) T foo(T, U)(U u) { return T.init; }
extern(C++) __gshared A!(A!int) aaint;
extern(C++) class Parent(T)
{
T parentMember;
final void parentFinal() {}
void parentVirtual() {}
}
extern(C++) final class Child(T) : Parent!T
{
T childMember;
override void parentVirtual() {}
T childFinal() { return T.init; }
}
extern(C++) void withDefTempl(A!int a = A!int(2)) {}
extern(C++) void withDefTempl2(T)(A!T a = A!T(2)) {}
extern(C++) alias withDefTempl2Inst = withDefTempl2!int;
extern(C++) class ChildInt : Parent!int {}
/******************************************************
* Mixins
*/
extern (C++):
mixin template MixinA(T)
{
void foo(T t) {}
}
mixin template MixinB() {}
struct HasMixins
{
mixin MixinA!int;
mixin MixinB;
}
struct HasMixinsTemplate(T)
{
mixin MixinA!T;
mixin MixinB;
}
__gshared HasMixinsTemplate!bool hmti;
/// Declarations that look like associative arrays
extern(D) enum SomeOtherLength = 1;
struct NotAA(T)
{
private:
enum length = 12;
public:
T[length] buffer;
T[SomeOtherLength] otherBuffer;
T[foo(1)] calcBuffer;
}
// Same name but hidden by the template paramter
extern (D) struct Buffer {}
extern (D) struct ActualBuffer {}
struct BufferTmpl(Buffer)
{
Buffer buffer;
mixin BufferMixin!();
}
struct ImportedBuffer
{
alias Buffer = ActualBuffer;
mixin BufferMixin!();
}
mixin template BufferMixin()
{
Buffer buffer2;
}
|