| @@ -5,6 +5,8 @@ typedef struct { int a; int b; int c; int d; int e; int f; int g; int h; } tstl; · 4 unmodified lines |
| 5 | 5 | typedef struct { int a; int b; int c; int d; } tsti; |
| 6 | 6 | typedef struct { double a; double b; } tstd; |
| 7 | 7 | typedef struct { long double a; } tstld; |
| 8 | +typedef struct { int a; double b; } tstm; |
| 9 | +typedef struct { float a; float b; float c; float d; } tstf; |
| 8 | 10 | |
| 9 | 11 | void incr_glob_i(int *i) |
| 10 | 12 | { |
| @@ -258,6 +260,44 @@ tstld test_cleanup5(void) { · 247 unmodified lines |
| 258 | 260 | return n; |
| 259 | 261 | } |
| 260 | 262 | |
| 263 | +void my_cleanup6(tstm *p) { |
| 264 | + printf("%d %g\n", p->a, p->b); |
| 265 | + p->a = 90; |
| 266 | + p->b = 91.0; |
| 267 | +} |
| 268 | + |
| 269 | +tstm test_cleanup6(void) { |
| 270 | + tstm __attribute__((cleanup(my_cleanup6))) n; |
| 271 | + n.a = 42; |
| 272 | + n.b = 43.0; |
| 273 | + return n; |
| 274 | +} |
| 275 | + |
| 276 | +void my_cleanup7(tstf *p) { |
| 277 | + printf("%f %f %f %f\n", p->a, p->b, p->c, p->d); |
| 278 | + p->a = 0x90; p->b = 0x91; p->c = 0x92; p->d = 0x93; |
| 279 | +} |
| 280 | + |
| 281 | +tstf test_cleanup7(void) { |
| 282 | + tstf __attribute__((cleanup(my_cleanup7))) n; |
| 283 | + n.a = 42; n.b = 43; n.c = 44; n.d = 45; |
| 284 | + return n; |
| 285 | +} |
| 286 | + |
| 287 | +void my_cleanup8(int **p) { |
| 288 | + **p = 0x90; |
| 289 | +} |
| 290 | + |
| 291 | +int test_cleanup8(void) { |
| 292 | + int n = 42; |
| 293 | + int __attribute__((cleanup(my_cleanup8))) *p = &n; |
| 294 | + return n; |
| 295 | +} |
| 296 | + |
| 297 | +static void my_cleanupe(int *p) { |
| 298 | + *p = 0x90; |
| 299 | +} |
| 300 | + |
| 261 | 301 | int main() |
| 262 | 302 | { |
| 263 | 303 | int i __attribute__ ((__cleanup__(check))) = 0, not_i; |
| @@ -267,6 +307,8 @@ int main() · 3 unmodified lines |
| 267 | 307 | tsti ti; |
| 268 | 308 | tstd td; |
| 269 | 309 | tstld tld; |
| 310 | + tstm tm; |
| 311 | + tstf tf; |
| 270 | 312 | |
| 271 | 313 | { |
| 272 | 314 | __attribute__ ((__cleanup__(check_oh_i))) char oh_i = 'o', o = 'a'; |
| @@ -299,6 +341,14 @@ int main() · 26 unmodified lines |
| 299 | 341 | printf("%g %g\n", td.a, td.b); |
| 300 | 342 | tld = test_cleanup5(); |
| 301 | 343 | printf("%Lf\n", tld.a); |
| 344 | + tm = test_cleanup6(); |
| 345 | + printf("%d %g\n", tm.a, tm.b); |
| 346 | + tf = test_cleanup7(); |
| 347 | + printf("%f %f %f %f\n", tf.a, tf.b, tf.c, tf.d); |
| 348 | + printf("%d\n", test_cleanup8()); |
| 349 | + printf("%d\n", ({ |
| 350 | + int __attribute__ ((cleanup(my_cleanupe))) n = 42; |
| 351 | + n; })); |
| 302 | 352 | return i; |
| 303 | 353 | } |
| 304 | 354 | |