gcc/testsuite/gcc.target/sparc/struct-ret-check-2.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O -mstd-struct-return" } */ |
| 3 | /* { dg-require-effective-target ilp32 } */ |
| 4 | |
| 5 | extern void abort (void); |
| 6 | |
| 7 | struct S { int x, y, z; }; |
| 8 | |
| 9 | extern void bar (struct S *s) __attribute__ ((noinline, noclone)); |
| 10 | |
| 11 | void bar (struct S *s) |
| 12 | { |
| 13 | s->x++; |
| 14 | } |
| 15 | |
| 16 | struct S foo (void) |
| 17 | { |
| 18 | struct S s = { 0, 2, 3 }; |
| 19 | bar (&s); |
| 20 | return s; |
| 21 | } |
| 22 | |
| 23 | int main (void) |
| 24 | { |
| 25 | struct S s = foo (); |
| 26 | if (s.x != 1) |
| 27 | abort (); |
| 28 | return 0; |
| 29 | } |