aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-ssa/pr41186.C
blob: cc685b207f1c80da3e4561b1042022f128dcd0db (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
/* { dg-do compile } */
/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */

struct Foo {
  Foo() {};
  int i;
  short f;
};
struct Bar : public Foo {
  Bar() {};
  short b;
};

extern "C" void abort(void);

int main()
{
  Bar b1, b2;
  b2.i = 0;
  b1.f = 0;
  b1.b = 1;
  b2.f = 1;
  b2.b = 2;
  static_cast<Foo&>(b1) = static_cast<Foo&>(b2);
  if (b1.i != 0 || b1.b != 1)
    abort ();
  if (b1.f != 1)
    abort ();
  return 0;
}

/* { dg-final { scan-tree-dump "Replaced b1.b with 1" "fre1" } } */
/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.i with 0" "fre1" } } */
/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.f with 1" "fre1" } } */
/* { dg-final { cleanup-tree-dump "fre1" } } */