-
Notifications
You must be signed in to change notification settings - Fork 31
/
issues.d
349 lines (321 loc) · 7.17 KB
/
issues.d
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
/**
Github issues.
*/
module issues;
import it;
@Tags("issue")
@("3")
@safe unittest {
shouldCompile(
C(
`
#include <signal.h>
`
),
D(
q{
siginfo_t si;
si._sifields._timer.si_tid = 2;
static assert(is(typeof(si.si_signo) == int));
static assert(is(typeof(si._sifields._timer.si_tid) == int),
typeof(si._sifields._timer.si_tid).stringof);
}
),
);
}
@Tags("issue")
@("4")
@safe unittest {
with(immutable IncludeSandbox()) {
writeFile("issue4.h",
q{
extern char *arr[9];
});
writeFile("issue4.dpp",
`
#include "issue4.h"
`);
runPreprocessOnly("issue4.dpp");
fileShouldContain("issue4.d", q{extern __gshared char*[9] arr;});
}
}
@Tags("issue")
@("5")
@safe unittest {
shouldCompile(
C(
q{
typedef enum zfs_error {
EZFS_SUCCESS = 0,
EZFS_NOMEM = 2000,
};
typedef struct zfs_perm_node {
char z_pname[4096];
} zfs_perm_node_t;
typedef struct libzfs_handle libzfs_handle_t;
}
),
D(
q{
zfs_error e1 = EZFS_SUCCESS;
zfs_error e2 = zfs_error.EZFS_SUCCESS;
zfs_perm_node_t node;
static assert(node.z_pname.sizeof == 4096);
static assert(is(typeof(node.z_pname[0]) == char), (typeof(node.z_pname[0]).stringof));
libzfs_handle_t* ptr;
}
),
);
}
@Tags("issue")
@("6")
@safe unittest {
with(immutable IncludeSandbox()) {
writeFile("issue6.h",
q{
char *getMessage();
});
writeFile("issue6.dpp",
`
#include "issue6.h"
`);
runPreprocessOnly("issue6.dpp");
fileShouldContain("issue6.d", q{char* getMessage() @nogc nothrow;});
}
}
@Tags("issue")
@("7")
@safe unittest {
shouldCompile(
C(
q{
struct splitflags {
int dryrun : 1;
int import : 2;
int name_flags;
int foo: 3;
int bar: 4;
int suffix;
};
struct other {
int quux: 2;
int toto: 3;
};
}
),
D(
q{
static assert(splitflags.sizeof == 16);
static assert(other.sizeof == 4);
}
),
);
}
@Tags("issue")
@("10")
@safe unittest {
shouldCompile(
C(
q{
enum silly_name {
FOO,
BAR,
BAZ,
};
extern void silly_name(enum silly_name thingie);
}
),
D(
q{
silly_name_(silly_name.FOO);
}
),
);
}
@Tags("issue")
@("11")
@safe unittest {
shouldCompile(
C(
q{
struct Foo;
typedef struct Foo* FooPtr;
}
),
D(
q{
FooPtr f = null;
static assert(!__traits(compiles, Foo()));
}
),
);
}
@Tags("issue")
@("14")
@safe unittest {
import dpp.runtime.options: Options;
with(immutable IncludeSandbox()) {
writeFile("foo.h",
q{
typedef int foo;
});
runPreprocessOnly("foo.h").shouldThrowWithMessage(
"No .dpp input file specified\n" ~ Options.usage);
}
}
@Tags("issue", "preprocessor")
@("22.1")
@safe unittest {
shouldCompile(
C(
`
typedef struct {
#ifdef __USE_XOPEN
int fds_bits[42];
#define __FDS_BITS(set) ((set)->fds_bits)
#else
int __fds_bits[42];
#define __FDS_BITS(set) ((set)->__fds_bits)
#endif
} fd_set;
`
),
D(
q{
fd_set set;
__FDS_BITS(set)[0] = 42;
}
),
);
}
@Tags("issue", "preprocessor")
@("22.2")
@safe unittest {
shouldCompile(
C(
`
#define SIZEOF(x) (sizeof(x))
`
),
D(
q{
int i;
static assert(SIZEOF(i) == 4);
}
),
);
}
@Tags("issue", "preprocessor")
@("22.3")
@safe unittest {
shouldCompile(
C(
`
typedef long int __fd_mask;
#define __NFDBITS (8 * (int) sizeof (__fd_mask))
`
),
D(
q{
import std.conv;
static assert(__NFDBITS == 8 * c_long.sizeof,
text("expected ", 8 * c_long.sizeof, ", got: ", __NFDBITS));
}
),
);
}
@Tags("issue", "preprocessor")
@("22.4")
@safe unittest {
shouldCompile(
C(
`
typedef struct clist { struct list* next; };
#define clist_next(iter) (iter ? (iter)->next : NULL)
`
),
D(
q{
clist l;
auto next = clist_next(&l);
}
),
);
}
@Tags("issue", "collision", "issue24")
@("24.1")
@safe unittest {
shouldCompile(
C(
q{
struct Bar {
void (*Foo)(void); // this should get renamed as Foo_
struct Foo* (*whatever)(void);
};
}
),
D(
q{
}
),
);
}
@Tags("issue", "collision", "issue24")
@("24.2")
@safe unittest {
shouldCompile(
C(
q{
int foo(int, struct foo_data**);
struct foo { int dummy; };
struct foo_data { int dummy; };
}
),
D(
q{
foo_data** data;
int ret = foo_(42, data);
foo s;
s.dummy = 33;
foo_data fd;
fd.dummy = 77;
}
),
);
}
@Tags("issue")
@("33.1")
@safe unittest {
shouldCompile(
C(
q{
void (*f)();
}
),
D(
q{
static extern(C) void printHello() { }
f = &printHello;
f();
}
),
);
}
@Tags("issue")
@("33.2")
@safe unittest {
shouldCompile(
C(
q{
int (*f)();
}
),
D(
q{
static extern(C) int func() { return 42; }
f = &func;
int i = f();
}
),
);
}