ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
with_gc
Last change
on this file since ef3403c6 was 80e8582, checked in by Rob Schluntz <rschlunt@…>, 8 years ago |
Move constructor/destructor tests to raii subdirectory
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | struct X {
|
---|
2 | int a;
|
---|
3 | int * ptr;
|
---|
4 | };
|
---|
5 |
|
---|
6 | void ?{}(X & this) {
|
---|
7 | printf("default constructing\n");
|
---|
8 | (this.a){ 123 };
|
---|
9 | this.ptr = (int *)malloc(sizeof(int));
|
---|
10 | }
|
---|
11 |
|
---|
12 | void ?{}(X & this, X other) {
|
---|
13 | printf("copy constructing\n");
|
---|
14 | (this.a){ other.a };
|
---|
15 | this.ptr = (int *)malloc(sizeof(int));
|
---|
16 | }
|
---|
17 |
|
---|
18 | void ?{}(X & this, int a) {
|
---|
19 | printf("constructing with %d\n", a);
|
---|
20 | (this.a){ a };
|
---|
21 | this.ptr = (int *)malloc(sizeof(int));
|
---|
22 | }
|
---|
23 |
|
---|
24 | void ^?{}(X & this) {
|
---|
25 | printf("destructing\n");
|
---|
26 | free(this.ptr);
|
---|
27 | }
|
---|
28 |
|
---|
29 | X ?=?(X & this, X other) {
|
---|
30 | this.a = other.a;
|
---|
31 | return this;
|
---|
32 | }
|
---|
33 |
|
---|
34 | X global[10][10] = {
|
---|
35 | { 1, { 2 }, { 3 }, { 4 }, 5, 6, 7, 8, 9, 10, 11, 12 },
|
---|
36 | { 1, 2, 3, 4 },
|
---|
37 | { { 1234567 } }
|
---|
38 | };
|
---|
39 |
|
---|
40 | X global2[3][3][3] = {
|
---|
41 | {
|
---|
42 | { 1, 2, 3 },
|
---|
43 | { 4, 5, 6 },
|
---|
44 | { 7, 8, 9 },
|
---|
45 | { 10, 11, 12 }
|
---|
46 | },
|
---|
47 | {
|
---|
48 | { 0, 0, 0 }
|
---|
49 | }
|
---|
50 | };
|
---|
51 |
|
---|
52 | int foo() {
|
---|
53 | static X abc[3][3] = {
|
---|
54 | { 11, 22, 33, 44 },
|
---|
55 | { 55, 66 },
|
---|
56 | { 77 },
|
---|
57 | { 88, 99, 1010 }
|
---|
58 | };
|
---|
59 | }
|
---|
60 |
|
---|
61 | // ensure constructed const arrays continue to compile
|
---|
62 | const int global[1] = { -2 };
|
---|
63 |
|
---|
64 | int main() {
|
---|
65 | X abc[4][4] = {
|
---|
66 | { 999, 1111 },
|
---|
67 | { 1, 2, 3, 4, 5 },
|
---|
68 | {},
|
---|
69 | { 0 },
|
---|
70 | { 88 }
|
---|
71 | };
|
---|
72 |
|
---|
73 | foo();
|
---|
74 | foo();
|
---|
75 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.