summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/nrv2.c
blob: e4d1f9aba3a7b0ef928a8947c5af4a07a19168d8 (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
/* Test that the tree_nrv pass works by making sure that we don't generate
   a memcpy.  Throw in a bit of control flow to make its job a bit harder.  */

/* { dg-options "-O" } */

struct A { int i[100]; };

int b;

struct A f ()
{
  struct A a;
  if (b)
    {
      a.i[0] = 42;
      return a;
    }
  else
    {
      a.i[42] = 1;
      return a;
    }
}

/* { dg-final { scan-assembler-not "memcpy" } } */