test3 wasn't working originally.
Unified · Split
| @@ -1,5 +1,4 @@ | |||
| 1 | #include <tcclib.h> | 1 | extern int printf(const char*, ...); |
| 2 | |||
| 3 | static int glob_i = 0; | 2 | static int glob_i = 0; |
| 4 | 3 | ||
| 5 | void incr_glob_i(int *i) | 4 | void incr_glob_i(int *i) |
| @@ -115,6 +114,41 @@ void test_ret2() · 109 unmodified lines | |||
| 115 | } | 114 | } |
| 116 | } | 115 | } |
| 117 | 116 | ||
| 117 | void test2(void) { | ||
| 118 | int chk = 0; | ||
| 119 | again: | ||
| 120 | if (!chk) { | ||
| 121 | char * __attribute__ ((cleanup(check2))) stop_that = "test2"; | ||
| 122 | chk++; | ||
| 123 | goto again; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | int test3(void) { | ||
| 128 | char * __attribute__ ((cleanup(check2))) stop_that = "three"; | ||
| 129 | int chk = 0; | ||
| 130 | |||
| 131 | if (chk) { | ||
| 132 | { | ||
| 133 | outside: | ||
| 134 | { | ||
| 135 | char * __attribute__ ((cleanup(check2))) stop_that = "two"; | ||
| 136 | printf("---- %d\n", chk); | ||
| 137 | } | ||
| 138 | } | ||
| 139 | } | ||
| 140 | if (!chk) | ||
| 141 | { | ||
| 142 | char * __attribute__ ((cleanup(check2))) stop_that = "one"; | ||
| 143 | |||
| 144 | if (!chk) { | ||
| 145 | chk = 1; | ||
| 146 | goto outside; | ||
| 147 | } | ||
| 148 | } | ||
| 149 | return 0; | ||
| 150 | } | ||
| 151 | |||
| 118 | int main() | 152 | int main() |
| 119 | { | 153 | { |
| 120 | int i __attribute__ ((__cleanup__(check))) = 0, not_i; | 154 | int i __attribute__ ((__cleanup__(check))) = 0, not_i; |
| @@ -138,6 +172,8 @@ int main() · 17 unmodified lines | |||
| 138 | printf("because what if free was call inside cleanup function\n", test()); | 172 | printf("because what if free was call inside cleanup function\n", test()); |
| 139 | test_ret(); | 173 | test_ret(); |
| 140 | test_ret2(); | 174 | test_ret2(); |
| 175 | test2(); | ||
| 176 | test3(); | ||
| 141 | return i; | 177 | return i; |
| 142 | } | 178 | } |
| 143 | 179 | ||
| @@ -10,6 +10,11 @@ str: that · 9 unmodified lines | |||
| 10 | str: this should appear only once | 10 | str: this should appear only once |
| 11 | str: -that2 | 11 | str: -that2 |
| 12 | str: -that | 12 | str: -that |
| 13 | str: test2 | ||
| 14 | str: one | ||
| 15 | ---- 1 | ||
| 16 | str: two | ||
| 17 | str: three | ||
| 13 | ---- 0 | 18 | ---- 0 |
| 14 | ---- 1 | 19 | ---- 1 |
| 15 | str: plop | 20 | str: plop |