aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/sparc/struct-ret-check-2.c
blob: 2b815345ab9ea055d0ba638fc5845b6583404213 (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
/* { dg-do run } */
/* { dg-options "-O -mstd-struct-return" } */
/* { dg-require-effective-target ilp32 } */

extern void abort (void);

struct S { int x, y, z; };

extern void bar (struct S *s) __attribute__ ((noinline, noclone));

void bar (struct S *s)
{
  s->x++;
}

struct S foo (void)
{
  struct S s = { 0, 2, 3 };
  bar (&s);
  return s;
}

int main (void)
{
  struct S s = foo ();
  if (s.x != 1)
    abort ();
  return 0;
}