summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/pr43655.C
blob: f7e370b9e426c4c1a66de80463dc42346f73605b (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
// PR tree-optimization/43655
// { dg-do run }
// { dg-options "-O0 -ftree-ter" }

extern "C" void abort ();

struct C
{
  C (int i) : val(i) { }
  C (const C& c) : val(c.val) { }
  ~C (void) { val = 999; }
  C& operator = (const C& c) { val = c.val; return *this; }
  C& inc (int i) { val += i; return *this; }
  int val;
};

C
f ()
{
  return C (3);
}

C
f (int i)
{
  return f ().inc (i);
}

int
main ()
{
  if (f (2).val != 5)
    abort ();
}