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
resolv-new
with_gc
Last change
on this file since d88f256a was 44f6341, checked in by Rob Schluntz <rschlunt@…>, 9 years ago |
fix implicit member ctor/dtor generation order, fix corresponding test
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | struct WrappedInt {
|
---|
2 | int x;
|
---|
3 | };
|
---|
4 |
|
---|
5 | void ?{}(WrappedInt * this) {
|
---|
6 | printf("constructing int\n");
|
---|
7 | this->x = 0;
|
---|
8 | }
|
---|
9 |
|
---|
10 | void ?{}(WrappedInt * this, WrappedInt other) {
|
---|
11 | printf("copy constructing int: %d\n", other.x);
|
---|
12 | this->x = other.x;
|
---|
13 | }
|
---|
14 |
|
---|
15 | void ?{}(WrappedInt * this, int x) {
|
---|
16 | printf("constructing int: %d\n", x);
|
---|
17 | this->x = x;
|
---|
18 | }
|
---|
19 |
|
---|
20 | void ^?{}(WrappedInt * this) {
|
---|
21 | printf("destructing int: %d\n", this->x);
|
---|
22 | }
|
---|
23 |
|
---|
24 | void ?=?(WrappedInt * this, int x) {
|
---|
25 | printf("assigning int: %d %d\n", this->x, x);
|
---|
26 | this->x = x;
|
---|
27 | }
|
---|
28 |
|
---|
29 | struct A {
|
---|
30 | WrappedInt x, y, z;
|
---|
31 | };
|
---|
32 |
|
---|
33 | void ?{}(A * a, int x) {
|
---|
34 | (&a->x){ x+999 };
|
---|
35 | a->y = 0; // not a constructor - default constructor will be inserted
|
---|
36 | } // z never constructed - will be automatically default constructed
|
---|
37 |
|
---|
38 | void ?{}(A * this, A other) {
|
---|
39 | (&this->x){ other.x };
|
---|
40 | this->y = other.y; // not a constructor - copy constructor will be inserted
|
---|
41 | } // z never constructed - will be automatically copy constructed
|
---|
42 |
|
---|
43 | struct B {
|
---|
44 | A a1, a2, a3;
|
---|
45 | };
|
---|
46 |
|
---|
47 | void ?{}(B * b) {
|
---|
48 | b->a2 = (A) { 2 };
|
---|
49 | (&b->a1){ 1 };
|
---|
50 | #ifdef ERR1
|
---|
51 | (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed
|
---|
52 | #endif
|
---|
53 | } // a2, a3 never constructed - will be automatically default constructed
|
---|
54 |
|
---|
55 | void ^?{}(B * b) {
|
---|
56 | b->a2 = (A) { 0 };
|
---|
57 | ^(&b->a1){};
|
---|
58 | } // a2, a3 never destructed - will be automatically destructed
|
---|
59 |
|
---|
60 | int main() {
|
---|
61 | printf("Before declaration of b1\n");
|
---|
62 | B b1;
|
---|
63 | printf("Before declaration of b2\n");
|
---|
64 | B b2 = b1;
|
---|
65 | printf("End of main\n");
|
---|
66 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.