Changeset a42a654 for tests/raii/memberCtors.c
- Timestamp:
- Aug 28, 2018, 6:30:11 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f8b69da7
- Parents:
- b54ad9c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/raii/memberCtors.c
rb54ad9c ra42a654 1 1 struct WrappedInt { 2 2 int x; 3 int id; 3 4 }; 5 int intID = 0; 4 6 5 7 void ?{}(WrappedInt & this) { 6 printf("constructing int\n"); 8 this.id = intID++; 9 printf("constructing int id: %d\n", this.id); 7 10 this.x = 0; 8 11 } 9 12 10 13 void ?{}(WrappedInt & this, WrappedInt other) { 11 printf("copy constructing int: %d\n", other.x); 14 this.id = intID++; 15 printf("copy constructing int: %d id: %d\n", other.x, this.id); 12 16 this.x = other.x; 13 17 } 14 18 15 19 void ?{}(WrappedInt & this, int x) { 16 printf("constructing int: %d\n", x); 20 this.id = intID++; 21 printf("constructing int: %d id: %d\n", x, this.id); 17 22 this.x = x; 18 23 } 19 24 20 25 void ^?{}(WrappedInt & this) { 21 printf("destructing int: %d \n", this.x);26 printf("destructing int: %d id: %d\n", this.x, this.id); 22 27 } 23 28 24 29 /* WrappedInt */ void ?=?(WrappedInt & this, int x) { 25 printf("assigning int: %d %d \n", this.x, x);30 printf("assigning int: %d %d id: %d\n", this.x, x, this.id); 26 31 this.x = x; 27 32 // return this; … … 36 41 struct A { 37 42 WrappedInt x, y, z; 43 int id; 38 44 }; 45 int AID = 0; 39 46 40 47 void ?{}(A & a) { 41 48 // currently must define default ctor, since there's no "= default" syntax 49 a.id = AID++; 50 printf("default construct A %d\n", a.id); 42 51 } 43 52 44 53 void ?{}(A & a, int x) { 45 printf("begin construct A\n"); 54 a.id = AID++; 55 printf("begin construct A id: %d\n", a.id); 46 56 printf("construct a.x\n"); 47 57 (a.x){ x+999 }; … … 52 62 53 63 void ?{}(A & this, A other) { 54 printf("begin copy construct A\n"); 64 this.id = AID++; 65 printf("begin copy construct A id: %d\n", this.id); 55 66 printf("copy construct this.x\n"); 56 67 (this.x){ other.x }; … … 61 72 62 73 A ?=?(A & this, A other) { 63 printf("begin ?=? A \n");74 printf("begin ?=? A id: %d\n", this.id); 64 75 this.x = other.x; 65 76 this.y = other.y; … … 71 82 struct B { 72 83 A a1, a2, a3; 84 int id; 73 85 }; 86 int BID = 0; 74 87 75 88 void ?{}(B & b) { 76 printf("begin construct B\n"); 89 b.id = BID++; 90 printf("begin construct B id: %d\n", b.id); 77 91 printf("assign b.a2\n"); 78 92 b.a2 = (A) { 2 }; … … 86 100 87 101 void ^?{}(B & b) { 88 printf("begin destruct B\n"); 102 b.id = BID++; 103 printf("begin destruct B id: %d\n", b.id); 89 104 b.a2 = (A) { 0 }; 90 105 ^(b.a1){};
Note: See TracChangeset
for help on using the changeset viewer.