| 1 |
/* PR target/5755 |
| 2 |
This testcase failed because the caller of a function returning struct |
| 3 |
expected the callee to pop up the hidden return structure pointer, |
| 4 |
while callee was actually not poping it up (as the hidden argument |
| 5 |
was passed in register). */ |
| 6 |
/* { dg-do run } */ |
| 7 |
/* { dg-options "-O2 -fomit-frame-pointer" } */ |
| 8 |
|
| 9 |
extern void abort (void); |
| 10 |
extern void exit (int); |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
int a1, a2; |
| 14 |
} A; |
| 15 |
|
| 16 |
A a; |
| 17 |
|
| 18 |
A __attribute__ ((regparm (2))) |
| 19 |
foo (int x) |
| 20 |
{ |
| 21 |
return a; |
| 22 |
} |
| 23 |
|
| 24 |
int __attribute__ ((regparm (2))) |
| 25 |
bar (int x) |
| 26 |
{ |
| 27 |
int r = foo(0).a2; |
| 28 |
return r; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
main () |
| 33 |
{ |
| 34 |
int f; |
| 35 |
a.a1 = 530; |
| 36 |
a.a2 = 980; |
| 37 |
f = bar (0); |
| 38 |
if (f != 980) |
| 39 |
abort (); |
| 40 |
exit (0); |
| 41 |
} |