aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/opt/pr30590.C
blob: 42ae046db81354a50e9a8bc94055add6499dacac (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
/* { dg-do run } */
/* { dg-options "-O" } */
struct test
{
  int type;
  char buffer[4242]; /* should trigger pass-by-reference */
};

int flag = 0;

struct test
reset (void)
{
  struct test retval;
  retval.type = 1;
  return retval;
}

struct test
test (void)
{
  struct test result;
  result.type = 0;

  for (int i = 0; i < 2; ++i)
    {
      struct test candidate = reset ();
      if (flag)
        result = candidate;
    }

  return result;
}

int
main (void)
{
  struct test result = test ();
  return result.type;
}