FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppjit/test/cpp/advancedcpp.h at main · compiler-research/cppjit · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
compiler-research
/
cppjit
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
12
Code
Issues
6
Pull requests
5
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppjit
/
test
/
cpp
/
advancedcpp.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
522 lines (422 loc) · 12.2 KB
Breadcrumbs
cppjit
/
test
/
cpp
/
advancedcpp.h
Copy path
File metadata and controls
522 lines (422 loc) · 12.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#
include
<
cstdint
>
#
include
<
new
>
#
include
<
ostream
>
#
include
<
string
>
#
include
<
vector
>
//
===========================================================================
#
define
DECLARE_DEFAULTERS
(
type, tname
) \
class
tname
##_defaulter { \
public:
\
tname##_defaulter(type a =
11
, type b =
22
, type c =
33
); \
\
public:
\
type m_a, m_b, m_c; \
}; \
type tname##_defaulter_func(
int
idx =
0
, type a =
11
, type b =
22
, \
type c =
33
);
DECLARE_DEFAULTERS
(
short
,
short
)
//
for testing of default arguments
DECLARE_DEFAULTERS
(
unsigned
short
, ushort)
DECLARE_DEFAULTERS
(
int
,
int
)
DECLARE_DEFAULTERS
(
unsigned
, uint)
DECLARE_DEFAULTERS
(
long
,
long
)
DECLARE_DEFAULTERS
(
unsigned
long
, ulong)
DECLARE_DEFAULTERS
(
long
long
, llong)
DECLARE_DEFAULTERS
(
unsigned
long
long
, ullong)
DECLARE_DEFAULTERS
(
float
,
float
)
DECLARE_DEFAULTERS
(
double
,
double
)
std::string
string_defaulter_func
(
int
idx,
const
std::string& name1 =
"
aap
"
,
std::string name2 =
"
noot
"
);
//
===========================================================================
class
base_class
{
//
for simple inheritance testing
public:
base_class
() {
m_b =
1
;
m_db =
1.1
;
}
virtual
~base_class
() {}
virtual
int
get_value
() {
return
m_b; }
double
get_base_value
() {
return
m_db; }
virtual
base_class*
cycle
(base_class* b) {
return
b; }
virtual
base_class*
clone
() {
return
new
base_class; }
virtual
void
*
mask
(
void
* p) {
return
p; }
public:
int
m_b;
double
m_db;
};
class
derived_class
:
public
base_class
{
public:
derived_class
() {
m_d =
2
;
m_dd =
2.2
;
}
virtual
int
get_value
() {
return
m_d; }
double
get_derived_value
() {
return
m_dd; }
virtual
base_class*
clone
() {
return
new
derived_class; }
public:
int
m_d;
double
m_dd;
};
//
===========================================================================
class
a_class
{
//
for esoteric inheritance testing
public:
a_class
() {
m_a =
1
;
m_da =
1.1
;
}
virtual
~a_class
() {}
virtual
int
get_value
() = 0;
public:
int
m_a;
double
m_da;
};
class
b_class
:
public
virtual
a_class {
public:
b_class
() {
m_b =
2
;
m_db =
2.2
;
}
virtual
int
get_value
() {
return
m_b; }
public:
int
m_b;
double
m_db;
};
class
c_class_1
:
public
virtual
a_class, public
virtual
b_class {
public:
c_class_1
() { m_c =
3
; }
virtual
int
get_value
() {
return
m_c; }
public:
int
m_c;
};
class
c_class_2
:
public
virtual
b_class, public
virtual
a_class {
public:
c_class_2
() { m_c =
3
; }
virtual
int
get_value
() {
return
m_c; }
public:
int
m_c;
};
typedef
c_class_2 c_class;
class
d_class
:
public
virtual
c_class, public
virtual
a_class {
public:
d_class
() { m_d =
4
; }
virtual
int
get_value
() {
return
m_d; }
public:
int
m_d;
};
a_class*
create_c1
();
a_class*
create_c2
();
int
get_a
(a_class& a);
int
get_b
(b_class& b);
int
get_c
(c_class& c);
int
get_d
(d_class& d);
//
===========================================================================
namespace
a_ns
{
//
for namespace testing
extern
int
g_a;
int
get_g_a
();
struct
b_class
{
b_class
() { m_b = -
2
; }
int
m_b;
static
int
s_b;
struct
c_class
{
c_class
() { m_c = -
3
; }
int
m_c;
static
int
s_c;
};
};
namespace
d_ns
{
extern
int
g_d;
int
get_g_d
();
struct
e_class
{
e_class
() { m_e = -
5
; }
int
m_e;
static
int
s_e;
struct
f_class
{
f_class
() { m_f = -
6
; }
int
m_f;
static
int
s_f;
};
};
}
//
namespace d_ns
}
//
namespace a_ns
//
===========================================================================
template
<
typename
T>
//
for template testing
class
T1
{
public:
T1
(T t = T(
1
)) : m_t1(t) {}
T
get_value
() {
return
m_t1; }
public:
T m_t1;
};
template
<
typename
T>
class
T2
{
public:
T2
(T t = T(
2
)) : m_t2(t) {}
T
get_value
() {
return
m_t2; }
public:
T m_t2;
};
template
<
typename
T,
typename
U>
class
T3
{
public:
T3
(T t = T(
3
), U u = U(
33
)) : m_t3(t), m_u3(u) {}
T
get_value_t
() {
return
m_t3; }
U
get_value_u
() {
return
m_u3; }
public:
T m_t3;
U m_u3;
};
namespace
a_ns
{
template
<
typename
T>
class
T4
{
public:
T4
(T t = T(
4
)) : m_t4(t) {}
T
get_value
() {
return
m_t4; }
public:
T m_t4;
};
}
//
namespace a_ns
extern
template
class
T1
<
int
>;
extern
template
class
T2
<
T1
<
int
>>;
extern
template
class
T3
<
int
,
double
>;
extern
template
class
T3
<
T1
<
int
>,
T2
<
T1
<
int
>>>;
extern
template
class
a_ns
::
T4
<
int
>;
extern
template
class
a_ns
::
T4
<a_ns::
T4
<
T3
<
int
,
double
>>>;
//
===========================================================================
//
for checking pass-by-reference of builtin types
void
set_int_through_ref
(
int
& i,
int
val);
int
pass_int_through_const_ref
(
const
int
& i);
void
set_long_through_ref
(
long
& l,
long
val);
long
pass_long_through_const_ref
(
const
long
& l);
void
set_double_through_ref
(
double
& d,
double
val);
double
pass_double_through_const_ref
(
const
double
& d);
//
===========================================================================
class
some_abstract_class
{
//
to test abstract class handling
public:
virtual
~some_abstract_class
() {}
virtual
void
a_virtual_method
() = 0;
};
class
some_concrete_class
:
public
some_abstract_class
{
public:
virtual
void
a_virtual_method
() {}
};
//
===========================================================================
class
ref_tester
{
//
for assignment by-ref testing
public:
ref_tester
() : m_i(-
99
) {}
ref_tester
(
int
i) : m_i(i) {}
ref_tester
(
const
ref_tester& s) : m_i(s.m_i) {}
ref_tester&
operator
=(
const
ref_tester& s) {
if
(&s !=
this
)
m_i = s.
m_i
;
return
*
this
;
}
~ref_tester
() {}
public:
int
m_i;
};
//
===========================================================================
class
some_convertible
{
//
for math conversions testing
public:
some_convertible
() : m_i(-
99
), m_d(-
99
.) {}
operator
int
() {
return
m_i; }
operator
long
() {
return
m_i; }
operator
double
() {
return
m_d; }
public:
int
m_i;
double
m_d;
};
class
some_comparable
{};
bool
operator
==(
const
some_comparable& c1,
const
some_comparable& c2);
bool
operator
!=(
const
some_comparable& c1,
const
some_comparable& c2);
//
===========================================================================
extern
double
my_global_double;
//
a couple of globals for access testing
extern
double
my_global_array[
500
];
extern
double
* my_global_ptr;
static
const
char
my_global_string1[] =
"
aap
"
"
noot
"
"
mies
"
;
extern
const
char
my_global_string2[];
extern
const
char
* my_global_string3[
3
];
class
some_int_holder
{
public:
some_int_holder
(
int
val) : m_val(val) {}
public:
int
m_val;
char
gap[
7
];
};
extern
some_int_holder my_global_int_holders[
5
];
extern
some_abstract_class* g_abstract_ptr;
//
===========================================================================
class
some_class_with_data
{
//
for life-line and identity testing
public:
class
some_data
{
public:
some_data
() { ++s_num_data; }
some_data
(
const
some_data&) { ++s_num_data; }
~some_data
() { --s_num_data; }
static
int
s_num_data;
};
some_class_with_data
gime_copy
() {
return
*
this
; }
const
some_data&
gime_data
() {
/*
TODO: methptrgetter const support
*/
return
m_data;
}
int
m_padding;
some_data m_data;
};
class
refers_to_self
{
//
for data member reuse testing
public:
refers_to_self* m_other =
nullptr
;
};
//
===========================================================================
class
pointer_pass
{
//
for testing passing of void*'s
public:
intptr_t
gime_address_ptr
(
void
* obj) {
return
(
intptr_t
)obj; }
intptr_t
gime_address_ptr_ptr
(
void
** obj) {
return
(
intptr_t
) * ((
long
**)obj);
}
intptr_t
gime_address_ptr_ref
(
const
void
*& obj) {
return
(
intptr_t
)obj; }
static
intptr_t
set_address_ptr_ptr
(
void
** obj) {
(*(
intptr_t
**)obj) = (
intptr_t
*)
0x4321
;
return
42
;
}
static
intptr_t
set_address_ptr_ref
(
const
void
*& obj) {
obj = (
void
*)
0x1234
;
return
21
;
}
};
//
===========================================================================
class
multi1
{
//
for testing multiple inheritance
public:
multi1
(
int
val) : m_int(val) {}
virtual
~multi1
();
int
get_multi1_int
() {
return
m_int; }
private:
int
m_int;
};
class
multi2
{
public:
multi2
(
int
val) : m_int(val) {}
virtual
~multi2
();
int
get_multi2_int
() {
return
m_int; }
private:
int
m_int;
};
class
multi
:
public
multi1
,
public
multi2
{
public:
multi
(
int
val1,
int
val2,
int
val3)
: multi1(val1), multi2(val2), m_int(val3) {}
virtual
~multi
();
int
get_my_own_int
() {
return
m_int; }
private:
int
m_int;
};
//
===========================================================================
class
new_overloader
{
//
for testing calls to overloaded new
public:
static
int
s_instances;
public:
void
*
operator
new
(std::
size_t
size);
void
*
operator
new
(std::
size_t
,
void
* p)
throw
();
void
operator
delete
(
void
* p, std::
size_t
size);
};
//
===========================================================================
template
<
class
T
>
//
more template testing
class
my_templated_class
{
public:
T m_b;
};
template
<
class
T
> T
my_templated_function
(T t) {
return
t; }
template
class
my_templated_class
<std::vector<
float
>>;
template
char
my_templated_function<
char
>(
char
);
template
double
my_templated_function<
double
>(
double
);
//
===========================================================================
class
overload_one_way
{
//
overload order testing
public:
int
gime
()
const
;
std::string
gime
();
};
class
overload_the_other_way
{
public:
std::string
gime
();
int
gime
()
const
;
};
//
===========================================================================
class
Thrower
{
//
exception handling testing
public:
void
throw_anything
();
void
throw_exception
();
};
//
===========================================================================
class
UsingBase1
{
//
using declaration testing
public:
UsingBase1
(
int
n =
13
) : m_int(n) {}
virtual
~UsingBase1
() {}
virtual
char
vcheck
() {
return
'
A
'
; }
int
m_int;
};
class
UsingDerived1
:
public
UsingBase1
{
public:
using
UsingBase1::UsingBase1;
virtual
char
vcheck
() {
return
'
B
'
; }
int
m_int2 =
42
;
};
class
UsingBase2
{
public:
virtual
~UsingBase2
() {}
virtual
char
vcheck
() {
return
'
A
'
; }
};
class
UsingDerived2
:
public
UsingBase2
{
public:
using
UsingBase2::vcheck;
virtual
char
vcheck
(
int
) {
return
'
B
'
; }
};
//
===========================================================================
class
TypedefToPrivateClass
{
//
typedef resolution testing
private:
class
PC
{
public:
PC
(
int
i) : m_val(i) {}
int
m_val;
};
public:
typedef
PC
PP
;
PP
f
() {
return
PC
(
42
); }
};
//
===========================================================================
namespace
Cpp2PyPrinting
{
//
operator to __str__ mapping
class
Printable1
{
public:
std::ostream&
operator
<<(std::ostream& os);
};
class
Printable2
{
/*
empty
*/
};
class
Printable3
{
/*
empty
*/
};
std::ostream&
operator
<<(std::ostream& os,
const
Printable2&);
}
//
namespace Cpp2PyPrinting
class
Printable4
{
/*
empty
*/
};
std::ostream&
operator
<<(std::ostream& os,
const
Cpp2PyPrinting::Printable3&);
std::ostream&
operator
<<(std::ostream& os,
const
Printable4&);
template
<
typename
T>
class
PrintableBase1
{};
class
Printable5
:
public
PrintableBase1
<
int
> {};
template
<
typename
T>
std::ostream&
operator
<<(std::ostream& os,
const
PrintableBase1<T>& y) {
return
os <<
"
Ok.
"
;
}
class
Printable6
{
public:
Printable6&
operator
<<(
int
);
};
std::ostream&
operator
<<(std::ostream& os,
const
Printable6& y);
//
===========================================================================
namespace
UsedSpace1
{
//
for using directives testing
int
foo1
();
namespace
inner
{
int
foo2
();
}
}
//
namespace UsedSpace1
namespace
UsedSpace2
{
int
bar
();
}
namespace
UserDirs
{
using
namespace
UsedSpace1
;
using
namespace
UsedSpace2
;
using
namespace
UsedSpace1
::inner
;
}
//
namespace UserDirs
Back
|
FazBrowse Home
|
New Git URL