- Also fix some gcc warning
Unified · Split
| @@ -149,10 +149,53 @@ int test3(void) { · 148 unmodified lines | ||
| 149 | 149 | return 0; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | +void cl(int *ip) | |
| 153 | +{ | |
| 154 | + printf("%d\n", *ip); | |
| 155 | +} | |
| 156 | + | |
| 157 | +void loop_cleanups(void) | |
| 158 | +{ | |
| 159 | + __attribute__((cleanup(cl))) int l = 1000; | |
| 160 | + | |
| 161 | + printf("-- loop 0 --\n"); | |
| 162 | + for ( __attribute__((cleanup(cl))) int i = 0; i < 10; ++i) { | |
| 163 | + __attribute__((cleanup(cl))) int j = 100; | |
| 164 | + } | |
| 165 | + | |
| 166 | + printf("-- loop 1 --\n"); | |
| 167 | + for (__attribute__((cleanup(cl))) int i = 0; i < 10; ++i) { | |
| 168 | + __attribute__((cleanup(cl))) int j = 200; | |
| 169 | + continue; | |
| 170 | + } | |
| 171 | + | |
| 172 | + printf("-- loop 2 --\n"); | |
| 173 | + for (__attribute__((cleanup(cl))) int i = 0; i < 10; ++i) { | |
| 174 | + __attribute__((cleanup(cl))) int j = 300; | |
| 175 | + break; | |
| 176 | + } | |
| 177 | + | |
| 178 | + printf("-- loop 3 --\n"); | |
| 179 | + for (int i = 0; i < 2; ++i) { | |
| 180 | + __attribute__((cleanup(cl))) int j = 400; | |
| 181 | + switch (i) { | |
| 182 | + case 0: | |
| 183 | + continue; | |
| 184 | + default: | |
| 185 | + { | |
| 186 | + __attribute__((cleanup(cl))) int jj = 500; | |
| 187 | + break; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } | |
| 191 | + printf("after break\n"); | |
| 192 | +} | |
| 193 | + | |
| 152 | 194 | int main() |
| 153 | 195 | { |
| 154 | 196 | int i __attribute__ ((__cleanup__(check))) = 0, not_i; |
| 155 | 197 | int chk = 0; |
| 198 | + (void)not_i; | |
| 156 | 199 | |
| 157 | 200 | { |
| 158 | 201 | __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'o', o = 'a'; |
| @@ -169,11 +212,12 @@ int main() · 10 unmodified lines | ||
| 169 | 212 | goto naaaaaaaa; |
| 170 | 213 | } |
| 171 | 214 | i = 105; |
| 172 | − printf("because what if free was call inside cleanup function\n", test()); | |
| 215 | + printf("because what if free was call inside cleanup function %s\n", test()); | |
| 173 | 216 | test_ret(); |
| 174 | 217 | test_ret2(); |
| 175 | 218 | test2(); |
| 176 | 219 | test3(); |
| 220 | + loop_cleanups(); | |
| 177 | 221 | return i; |
| 178 | 222 | } |
| 179 | 223 | |
| @@ -4,7 +4,7 @@ glob_i: 65536 · 3 unmodified lines | ||
| 4 | 4 | oo: 2.600000 |
| 5 | 5 | c: f |
| 6 | 6 | str: I don't think this should be print(but gcc got it wrong too) |
| 7 | −because what if free was call inside cleanup function | |
| 7 | +because what if free was call inside cleanup function I don't think this should be print(but gcc got it wrong too) | |
| 8 | 8 | should be print before |
| 9 | 9 | str: that |
| 10 | 10 | str: this should appear only once |
| @@ -15,6 +15,39 @@ str: one · 4 unmodified lines | ||
| 15 | 15 | ---- 1 |
| 16 | 16 | str: two |
| 17 | 17 | str: three |
| 18 | +-- loop 0 -- | |
| 19 | +100 | |
| 20 | +100 | |
| 21 | +100 | |
| 22 | +100 | |
| 23 | +100 | |
| 24 | +100 | |
| 25 | +100 | |
| 26 | +100 | |
| 27 | +100 | |
| 28 | +100 | |
| 29 | +10 | |
| 30 | +-- loop 1 -- | |
| 31 | +200 | |
| 32 | +200 | |
| 33 | +200 | |
| 34 | +200 | |
| 35 | +200 | |
| 36 | +200 | |
| 37 | +200 | |
| 38 | +200 | |
| 39 | +200 | |
| 40 | +200 | |
| 41 | +10 | |
| 42 | +-- loop 2 -- | |
| 43 | +300 | |
| 44 | +0 | |
| 45 | +-- loop 3 -- | |
| 46 | +400 | |
| 47 | +500 | |
| 48 | +400 | |
| 49 | +after break | |
| 50 | +1000 | |
| 18 | 51 | ---- 0 |
| 19 | 52 | ---- 1 |
| 20 | 53 | str: plop |