Changeset a42a654 for tests/raii
- 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
- Location:
- tests/raii
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/raii/.expect/memberCtors-ERR1.txt
rb54ad9c ra42a654 1 raii/memberCtors.c: 71:1 error: in void ?{}(B &b), field a2 used before being constructed1 raii/memberCtors.c:92:1 error: in void ?{}(B &b), field a2 used before being constructed -
tests/raii/.expect/memberCtors.txt
rb54ad9c ra42a654 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 begin destruct B 101 constructing int 102 constructing int 103 begin construct A 104 construct a.x 105 constructing int: 999 106 assign a.y 107 assigning int: 0 0 108 end construct A 109 copy constructing int: 0 110 copy constructing int: 0 111 begin copy construct A 112 copy construct this.x 113 copy constructing int: 999 114 assign this.y 115 copy constructing int: 0 116 destructing int: 0 117 destructing int: 0 118 end copy construct A 119 begin ?=? A 120 copy constructing int: 999 121 destructing int: 999 122 destructing int: 999 123 copy constructing int: 0 124 destructing int: 0 125 destructing int: 0 126 copy constructing int: 0 127 destructing int: 0 128 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 129 131 end ?=? A 130 copy constructing int: 0 131 copy constructing int: 0 132 begin copy construct A 133 copy construct this.x 134 copy constructing int: 999 135 assign this.y 136 copy constructing int: 0 137 destructing int: 0 138 destructing int: 0 139 end copy construct A 140 destructing int: 0 141 destructing int: 0 142 destructing int: 999 143 destructing int: 0 144 destructing int: 0 145 destructing int: 999 146 destructing int: 0 147 destructing int: 0 148 destructing int: 1000 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 149 151 end destruct B 150 destructing int: 0 151 destructing int: 0 152 destructing int: 999 153 destructing int: 0 154 destructing int: 0 155 destructing int: 0 156 destructing int: 0 157 destructing int: 0 158 destructing int: 999 159 begin destruct B 160 constructing int 161 constructing int 162 begin construct A 163 construct a.x 164 constructing int: 999 165 assign a.y 166 assigning int: 0 0 167 end construct A 168 copy constructing int: 0 169 copy constructing int: 0 170 begin copy construct A 171 copy construct this.x 172 copy constructing int: 999 173 assign this.y 174 copy constructing int: 0 175 destructing int: 0 176 destructing int: 0 177 end copy construct A 178 begin ?=? A 179 copy constructing int: 999 180 destructing int: 999 181 destructing int: 999 182 copy constructing int: 0 183 destructing int: 0 184 destructing int: 0 185 copy constructing int: 0 186 destructing int: 0 187 destructing int: 0 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 188 190 end ?=? A 189 copy constructing int: 0 190 copy constructing int: 0 191 begin copy construct A 192 copy construct this.x 193 copy constructing int: 999 194 assign this.y 195 copy constructing int: 0 196 destructing int: 0 197 destructing int: 0 198 end copy construct A 199 destructing int: 0 200 destructing int: 0 201 destructing int: 999 202 destructing int: 0 203 destructing int: 0 204 destructing int: 999 205 destructing int: 0 206 destructing int: 0 207 destructing int: 1000 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 208 210 end destruct B 209 destructing int: 0 210 destructing int: 0 211 destructing int: 999 212 destructing int: 0 213 destructing int: 0 214 destructing int: 0 215 destructing int: 0 216 destructing int: 0 217 destructing int: 999 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.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.