gcc/testsuite/gcc.c-torture/compile/pr26840.c
raw| 1 | extern int f1 (void **); |
| 2 | extern void f2 (void *); |
| 3 | |
| 4 | struct s |
| 5 | { |
| 6 | unsigned char field1; |
| 7 | int field2; |
| 8 | }; |
| 9 | |
| 10 | static inline struct s * |
| 11 | get_globals (void) |
| 12 | { |
| 13 | struct s * r; |
| 14 | void * rr; |
| 15 | |
| 16 | if (f1 (&rr)) |
| 17 | return 0; |
| 18 | r = rr; |
| 19 | if (! r) |
| 20 | { |
| 21 | extern struct s t; |
| 22 | r = &t; |
| 23 | } |
| 24 | r->field1 = 1; |
| 25 | return r; |
| 26 | } |
| 27 | |
| 28 | void |
| 29 | atexit_common (const void *dso) |
| 30 | { |
| 31 | struct s *g = get_globals (); |
| 32 | |
| 33 | if (! g) |
| 34 | return; |
| 35 | if (g->field1) |
| 36 | { |
| 37 | g->field2 = 0; |
| 38 | f2 (g); |
| 39 | } |
| 40 | else |
| 41 | f2 (g); |
| 42 | } |