Changeset f57dd25 for tests/raii
- Timestamp:
- May 29, 2019, 3:45:00 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 0aedb01
- Parents:
- 157a816 (diff), ebc0a85 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- tests/raii
- Files:
-
- 3 edited
-
.expect/memberCtors-ERR1.txt (modified) (1 diff)
-
.expect/memberCtors.txt (modified) (1 diff)
-
memberCtors.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/raii/.expect/memberCtors-ERR1.txt
r157a816 rf57dd25 1 raii/memberCtors.cfa: 71:1 error: in void ?{}(B &b), field a2 used before being constructed1 raii/memberCtors.cfa:92:1 error: in void ?{}(B &b), field a2 used before being constructed -
tests/raii/.expect/memberCtors.txt
r157a816 rf57dd25 1 1 Before declaration of b1 2 constructing int 3 constructing int 4 constructing int 5 constructing int 6 constructing int 7 constructing int 8 begin construct B 2 constructing int id: 0 3 constructing int id: 1 4 constructing int id: 2 5 default construct A 0 6 constructing int id: 3 7 constructing int id: 4 8 constructing int id: 5 9 default construct A 1 10 begin construct B id: 0 9 11 assign b.a2 10 constructing int 11 constructing int 12 begin construct A 13 construct a.x 14 constructing int: 1001 15 assign a.y 16 assigning int: 0 0 17 end construct A 18 copy constructing int: 0 19 copy constructing int: 0 20 begin copy construct A 21 copy construct this.x 22 copy constructing int: 1001 23 assign this.y 24 copy constructing int: 0 25 destructing int: 0 26 destructing int: 0 27 end copy construct A 28 begin ?=? A 29 copy constructing int: 1001 30 destructing int: 1001 31 destructing int: 1001 32 copy constructing int: 0 33 destructing int: 0 34 destructing int: 0 35 copy constructing int: 0 36 destructing int: 0 37 destructing int: 0 12 constructing int id: 6 13 constructing int id: 7 14 begin construct A id: 2 15 construct a.x 16 constructing int: 1001 id: 8 17 assign a.y 18 assigning int: 0 0 id: 6 19 end construct A 20 copy constructing int: 0 id: 9 21 copy constructing int: 0 id: 10 22 begin copy construct A id: 3 23 copy construct this.x 24 copy constructing int: 1001 id: 11 25 assign this.y 26 copy constructing int: 0 id: 12 27 destructing int: 0 id: 12 28 destructing int: 0 id: 12 29 end copy construct A 30 begin ?=? A id: 0 31 copy constructing int: 1001 id: 13 32 destructing int: 1001 id: 13 33 destructing int: 1001 id: 13 34 copy constructing int: 0 id: 14 35 destructing int: 0 id: 14 36 destructing int: 0 id: 14 37 copy constructing int: 0 id: 15 38 destructing int: 0 id: 15 39 destructing int: 0 id: 15 38 40 end ?=? A 39 copy constructing int: 0 40 copy constructing int: 0 41 begin copy construct A 42 copy construct this.x 43 copy constructing int: 1001 44 assign this.y 45 copy constructing int: 0 46 destructing int: 0 47 destructing int: 0 48 end copy construct A 49 destructing int: 0 50 destructing int: 0 51 destructing int: 1001 52 destructing int: 0 53 destructing int: 0 54 destructing int: 1001 41 copy constructing int: 0 id: 16 42 copy constructing int: 0 id: 17 43 begin copy construct A id: 4 44 copy construct this.x 45 copy constructing int: 1001 id: 18 46 assign this.y 47 copy constructing int: 0 id: 19 48 destructing int: 0 id: 19 49 destructing int: 0 id: 19 50 end copy construct A 51 destructing int: 0 id: 17 52 destructing int: 0 id: 19 53 destructing int: 1001 id: 18 54 destructing int: 0 id: 10 55 destructing int: 0 id: 12 56 destructing int: 1001 id: 11 55 57 construct b.a1 56 constructing int 57 constructing int 58 begin construct A 59 construct a.x 60 constructing int: 1000 61 assign a.y 62 assigning int: 0 0 58 constructing int id: 20 59 constructing int id: 21 60 begin construct A id: 5 61 construct a.x 62 constructing int: 1000 id: 22 63 assign a.y 64 assigning int: 0 0 id: 20 63 65 end construct A 64 66 end construct B 65 destructing int: 0 66 destructing int: 0 67 destructing int: 1001 67 destructing int: 0 id: 7 68 destructing int: 0 id: 6 69 destructing int: 1001 id: 8 68 70 Before declaration of b2 69 copy constructing int: 0 70 copy constructing int: 0 71 begin copy construct A 72 copy construct this.x 73 copy constructing int: 1000 74 assign this.y 75 copy constructing int: 0 76 destructing int: 0 77 destructing int: 0 78 end copy construct A 79 copy constructing int: 0 80 copy constructing int: 0 81 begin copy construct A 82 copy construct this.x 83 copy constructing int: 1001 84 assign this.y 85 copy constructing int: 0 86 destructing int: 0 87 destructing int: 0 88 end copy construct A 89 copy constructing int: 0 90 copy constructing int: 0 91 begin copy construct A 92 copy construct this.x 93 copy constructing int: 0 94 assign this.y 95 copy constructing int: 0 96 destructing int: 0 97 destructing int: 0 71 copy constructing int: 0 id: 23 72 copy constructing int: 0 id: 24 73 begin copy construct A id: 6 74 copy construct this.x 75 copy constructing int: 1000 id: 25 76 assign this.y 77 copy constructing int: 0 id: 26 78 destructing int: 0 id: 26 79 destructing int: 0 id: 26 80 end copy construct A 81 copy constructing int: 0 id: 27 82 copy constructing int: 0 id: 28 83 begin copy construct A id: 7 84 copy construct this.x 85 copy constructing int: 1001 id: 29 86 assign this.y 87 copy constructing int: 0 id: 30 88 destructing int: 0 id: 30 89 destructing int: 0 id: 30 90 end copy construct A 91 copy constructing int: 0 id: 31 92 copy constructing int: 0 id: 32 93 begin copy construct A id: 8 94 copy construct this.x 95 copy constructing int: 0 id: 33 96 assign this.y 97 copy constructing int: 0 id: 34 98 destructing int: 0 id: 34 99 destructing int: 0 id: 34 98 100 end copy construct A 99 101 End of main 100 constructing int 101 constructing int 102 begin construct A 103 construct a.x 104 constructing int: 999 105 assign a.y 106 assigning int: 0 0 107 end construct A 108 copy constructing int: 0 109 copy constructing int: 0 110 begin copy construct A 111 copy construct this.x 112 copy constructing int: 999 113 assign this.y 114 copy constructing int: 0 115 destructing int: 0 116 destructing int: 0 117 end copy construct A 118 begin ?=? A 119 copy constructing int: 999 120 destructing int: 999 121 destructing int: 999 122 copy constructing int: 0 123 destructing int: 0 124 destructing int: 0 125 copy constructing int: 0 126 destructing int: 0 127 destructing int: 0 102 begin destruct B id: 1 103 constructing int id: 35 104 constructing int id: 36 105 begin construct A id: 9 106 construct a.x 107 constructing int: 999 id: 37 108 assign a.y 109 assigning int: 0 0 id: 35 110 end construct A 111 copy constructing int: 0 id: 38 112 copy constructing int: 0 id: 39 113 begin copy construct A id: 10 114 copy construct this.x 115 copy constructing int: 999 id: 40 116 assign this.y 117 copy constructing int: 0 id: 41 118 destructing int: 0 id: 41 119 destructing int: 0 id: 41 120 end copy construct A 121 begin ?=? A id: 7 122 copy constructing int: 999 id: 42 123 destructing int: 999 id: 42 124 destructing int: 999 id: 42 125 copy constructing int: 0 id: 43 126 destructing int: 0 id: 43 127 destructing int: 0 id: 43 128 copy constructing int: 0 id: 44 129 destructing int: 0 id: 44 130 destructing int: 0 id: 44 128 131 end ?=? A 129 copy constructing int: 0 130 copy constructing int: 0 131 begin copy construct A 132 copy construct this.x 133 copy constructing int: 999 134 assign this.y 135 copy constructing int: 0 136 destructing int: 0 137 destructing int: 0 138 end copy construct A 139 destructing int: 0 140 destructing int: 0 141 destructing int: 999 142 destructing int: 0 143 destructing int: 0 144 destructing int: 999 145 destructing int: 0 146 destructing int: 0 147 destructing int: 1000 148 destructing int: 0 149 destructing int: 0 150 destructing int: 999 151 destructing int: 0 152 destructing int: 0 153 destructing int: 0 154 destructing int: 0 155 destructing int: 0 156 destructing int: 999 157 constructing int 158 constructing int 159 begin construct A 160 construct a.x 161 constructing int: 999 162 assign a.y 163 assigning int: 0 0 164 end construct A 165 copy constructing int: 0 166 copy constructing int: 0 167 begin copy construct A 168 copy construct this.x 169 copy constructing int: 999 170 assign this.y 171 copy constructing int: 0 172 destructing int: 0 173 destructing int: 0 174 end copy construct A 175 begin ?=? A 176 copy constructing int: 999 177 destructing int: 999 178 destructing int: 999 179 copy constructing int: 0 180 destructing int: 0 181 destructing int: 0 182 copy constructing int: 0 183 destructing int: 0 184 destructing int: 0 132 copy constructing int: 0 id: 45 133 copy constructing int: 0 id: 46 134 begin copy construct A id: 11 135 copy construct this.x 136 copy constructing int: 999 id: 47 137 assign this.y 138 copy constructing int: 0 id: 48 139 destructing int: 0 id: 48 140 destructing int: 0 id: 48 141 end copy construct A 142 destructing int: 0 id: 46 143 destructing int: 0 id: 48 144 destructing int: 999 id: 47 145 destructing int: 0 id: 39 146 destructing int: 0 id: 41 147 destructing int: 999 id: 40 148 destructing int: 0 id: 24 149 destructing int: 0 id: 26 150 destructing int: 1000 id: 25 151 end destruct B 152 destructing int: 0 id: 36 153 destructing int: 0 id: 35 154 destructing int: 999 id: 37 155 destructing int: 0 id: 32 156 destructing int: 0 id: 34 157 destructing int: 0 id: 33 158 destructing int: 0 id: 44 159 destructing int: 0 id: 43 160 destructing int: 999 id: 42 161 begin destruct B id: 2 162 constructing int id: 49 163 constructing int id: 50 164 begin construct A id: 12 165 construct a.x 166 constructing int: 999 id: 51 167 assign a.y 168 assigning int: 0 0 id: 49 169 end construct A 170 copy constructing int: 0 id: 52 171 copy constructing int: 0 id: 53 172 begin copy construct A id: 13 173 copy construct this.x 174 copy constructing int: 999 id: 54 175 assign this.y 176 copy constructing int: 0 id: 55 177 destructing int: 0 id: 55 178 destructing int: 0 id: 55 179 end copy construct A 180 begin ?=? A id: 0 181 copy constructing int: 999 id: 56 182 destructing int: 999 id: 56 183 destructing int: 999 id: 56 184 copy constructing int: 0 id: 57 185 destructing int: 0 id: 57 186 destructing int: 0 id: 57 187 copy constructing int: 0 id: 58 188 destructing int: 0 id: 58 189 destructing int: 0 id: 58 185 190 end ?=? A 186 copy constructing int: 0 187 copy constructing int: 0 188 begin copy construct A 189 copy construct this.x 190 copy constructing int: 999 191 assign this.y 192 copy constructing int: 0 193 destructing int: 0 194 destructing int: 0 195 end copy construct A 196 destructing int: 0 197 destructing int: 0 198 destructing int: 999 199 destructing int: 0 200 destructing int: 0 201 destructing int: 999 202 destructing int: 0 203 destructing int: 0 204 destructing int: 1000 205 destructing int: 0 206 destructing int: 0 207 destructing int: 999 208 destructing int: 0 209 destructing int: 0 210 destructing int: 0 211 destructing int: 0 212 destructing int: 0 213 destructing int: 999 191 copy constructing int: 0 id: 59 192 copy constructing int: 0 id: 60 193 begin copy construct A id: 14 194 copy construct this.x 195 copy constructing int: 999 id: 61 196 assign this.y 197 copy constructing int: 0 id: 62 198 destructing int: 0 id: 62 199 destructing int: 0 id: 62 200 end copy construct A 201 destructing int: 0 id: 60 202 destructing int: 0 id: 62 203 destructing int: 999 id: 61 204 destructing int: 0 id: 53 205 destructing int: 0 id: 55 206 destructing int: 999 id: 54 207 destructing int: 0 id: 21 208 destructing int: 0 id: 20 209 destructing int: 1000 id: 22 210 end destruct B 211 destructing int: 0 id: 50 212 destructing int: 0 id: 49 213 destructing int: 999 id: 51 214 destructing int: 0 id: 5 215 destructing int: 0 id: 4 216 destructing int: 0 id: 3 217 destructing int: 0 id: 58 218 destructing int: 0 id: 57 219 destructing int: 999 id: 56 -
tests/raii/memberCtors.cfa
r157a816 rf57dd25 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 void ?=?(WrappedInt & this, int x) {25 printf("assigning int: %d %d \n", this.x, x);29 /* WrappedInt */ void ?=?(WrappedInt & this, int x) { 30 printf("assigning int: %d %d id: %d\n", this.x, x, this.id); 26 31 this.x = x; 32 // return this; 27 33 } 34 35 // WrappedInt ?=?(WrappedInt & this, WrappedInt other) { 36 // printf("assigning int: %d %d\n", this.x, other.x); 37 // this.x = other.x; 38 // return this; 39 // } 28 40 29 41 struct A { 30 42 WrappedInt x, y, z; 43 int id; 31 44 }; 45 int AID = 0; 32 46 33 47 void ?{}(A & a) { 34 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); 35 51 } 36 52 37 53 void ?{}(A & a, int x) { 38 printf("begin construct A\n"); 54 a.id = AID++; 55 printf("begin construct A id: %d\n", a.id); 39 56 printf("construct a.x\n"); 40 57 (a.x){ x+999 }; … … 45 62 46 63 void ?{}(A & this, A other) { 47 printf("begin copy construct A\n"); 64 this.id = AID++; 65 printf("begin copy construct A id: %d\n", this.id); 48 66 printf("copy construct this.x\n"); 49 67 (this.x){ other.x }; … … 54 72 55 73 A ?=?(A & this, A other) { 56 printf("begin ?=? A \n");74 printf("begin ?=? A id: %d\n", this.id); 57 75 this.x = other.x; 58 76 this.y = other.y; … … 64 82 struct B { 65 83 A a1, a2, a3; 84 int id; 66 85 }; 86 int BID = 0; 67 87 68 88 void ?{}(B & b) { 69 printf("begin construct B\n"); 89 b.id = BID++; 90 printf("begin construct B id: %d\n", b.id); 70 91 printf("assign b.a2\n"); 71 92 b.a2 = (A) { 2 }; … … 79 100 80 101 void ^?{}(B & b) { 102 b.id = BID++; 103 printf("begin destruct B id: %d\n", b.id); 81 104 b.a2 = (A) { 0 }; 82 105 ^(b.a1){}; 106 printf("end destruct B\n"); 83 107 } // a2, a3 never destructed - will be automatically destructed 84 108 85 109 int main() { 86 110 printf("Before declaration of b1\n"); 87 B b1; 111 B b1; // b1 = { { 1000, 0, 0 }, { 1001, 0, 0 }, { 0, 0, 0 } } 88 112 printf("Before declaration of b2\n"); 89 113 B b2 = b1;
Note:
See TracChangeset
for help on using the changeset viewer.