aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/s390/return-addr2.c
blob: c94d052840b1a135e109de86c9bb5ab60fcb62bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* builtin_return_address(n) with n>0 has always been troublesome.  */

/* { dg-do run } */
/* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain" } */

void *addr1;

extern void abort (void);

void * __attribute__((noinline))
foo1 ()
{
  addr1 = __builtin_return_address (2);
}

void * __attribute__((noinline))
foo2 ()
{
  foo1 ();
}

void * __attribute__((noinline))
foo3 ()
{
  foo2 ();
}

void __attribute__((noinline))
bar ()
{
  void *addr2;

  foo3 ();
  asm volatile ("basr  %0,0\n\t" : "=d" (addr2));
  /* basr is two bytes in length.  */
  if (addr2 - addr1 != 2)
    abort ();
}

int
main ()
{
  bar();
  return 0;
}