Debian Codegraph @

gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-1.c

raw
1 /* PR middle-end/11151 */
2 /* Originator: Andrew Church <[email protected]> */
3 /* { dg-do run } */
4 /* { dg-require-effective-target untyped_assembly } */
5
6 /* This used to fail on SPARC because the (undefined) return
7 value of 'bar' was overwriting that of 'foo'. */
8
9 #ifdef __MMIX__
10 /* No parameters on stack for bar. */
11 #define STACK_ARGUMENTS_SIZE 0
12 #else
13 #define STACK_ARGUMENTS_SIZE 64
14 #endif
15
16 extern void abort(void);
17
18 int foo(int n)
19 {
20 return n+1;
21 }
22
23 int bar(int n)
24 {
25 __builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(),
26 STACK_ARGUMENTS_SIZE));
27 }
28
29 int main(void)
30 {
31 /* Allocate 64 bytes on the stack to make sure that __builtin_apply
32 can read at least 64 bytes above the return address. */
33 char dummy[64];
34
35 __asm__ ("" : : "" (dummy));
36
37 if (bar(1) != 2)
38 abort();
39
40 return 0;
41 }