1 extern int printf(const char*, ...);
4 void incr_glob_i(int *i
)
10 int i __attribute__ ((__cleanup__(incr_glob_i))) = 1; \
13 #define INCR_GI0 INCR_GI INCR_GI INCR_GI INCR_GI
14 #define INCR_GI1 INCR_GI0 INCR_GI0 INCR_GI0 INCR_GI0
15 #define INCR_GI2 INCR_GI1 INCR_GI1 INCR_GI1 INCR_GI1
16 #define INCR_GI3 INCR_GI2 INCR_GI2 INCR_GI2 INCR_GI2
17 #define INCR_GI4 INCR_GI3 INCR_GI3 INCR_GI3 INCR_GI3
18 #define INCR_GI5 INCR_GI4 INCR_GI4 INCR_GI4 INCR_GI4
19 #define INCR_GI6 INCR_GI5 INCR_GI5 INCR_GI5 INCR_GI5
20 #define INCR_GI7 INCR_GI6 INCR_GI6 INCR_GI6 INCR_GI6
23 void check2(char **hum
);
27 char * __attribute__ ((cleanup(check2
))) stop_that
= "wololo";
31 char * __attribute__ ((cleanup(check2
))) stop_that
= "plop";
35 printf("---- %d\n", chk
);
44 char * __attribute__ ((cleanup(check2
))) stop_that
= "tata !";
52 char * __attribute__ ((cleanup(check2
))) cascade1
= "1";
54 char * __attribute__ ((cleanup(check2
))) cascade2
= "2";
56 char * __attribute__ ((cleanup(check2
))) cascade3
= "3";
68 char * __attribute__ ((cleanup(check2
))) out
= "last goto out";
77 void check_oh_i(char *oh_i
)
79 printf("c: %c\n", *oh_i
);
82 void goto_hell(double *f
)
84 printf("oo: %f\n", *f
);
89 char *__attribute__ ((cleanup(check2
))) str
= "I don't think this should be print(but gcc got it wrong too)";
94 void test_ret_subcall(char *that
)
96 printf("should be print before\n");
101 char *__attribute__ ((cleanup(check2
))) that
= "that";
102 return test_ret_subcall(that
);
107 char *__attribute__ ((cleanup(check2
))) that
= "-that";
109 char *__attribute__ ((cleanup(check2
))) that
= "this should appear only once";
112 char *__attribute__ ((cleanup(check2
))) that
= "-that2";
121 char * __attribute__ ((cleanup(check2
))) stop_that
= "test2";
128 char * __attribute__ ((cleanup(check2
))) stop_that
= "three";
135 char * __attribute__ ((cleanup(check2
))) stop_that
= "two";
136 printf("---- %d\n", chk
);
142 char * __attribute__ ((cleanup(check2
))) stop_that
= "one";
157 void loop_cleanups(void)
159 __attribute__((cleanup(cl
))) int l
= 1000;
161 printf("-- loop 0 --\n");
162 for ( __attribute__((cleanup(cl
))) int i
= 0; i
< 10; ++i
) {
163 __attribute__((cleanup(cl
))) int j
= 100;
166 printf("-- loop 1 --\n");
167 for (__attribute__((cleanup(cl
))) int i
= 0; i
< 10; ++i
) {
168 __attribute__((cleanup(cl
))) int j
= 200;
172 printf("-- loop 2 --\n");
173 for (__attribute__((cleanup(cl
))) int i
= 0; i
< 10; ++i
) {
174 __attribute__((cleanup(cl
))) int j
= 300;
178 printf("-- loop 3 --\n");
179 for (int i
= 0; i
< 2; ++i
) {
180 __attribute__((cleanup(cl
))) int j
= 400;
186 __attribute__((cleanup(cl
))) int jj
= 500;
191 printf("after break\n");
196 int i
__attribute__ ((__cleanup__(check
))) = 0, not_i
;
201 __attribute__ ((__cleanup__(check_oh_i
))) char oh_i
= 'o', o
= 'a';
205 printf("glob_i: %d\n", glob_i
);
208 __attribute__ ((__cleanup__(check_oh_i
))) char oh_i
= 'f';
209 double __attribute__ ((__cleanup__(goto_hell
))) f
= 2.6;
215 printf("because what if free was call inside cleanup function %s\n", test());
224 void check2(char **hum
)
226 printf("str: %s\n", *hum
);