summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr46734.C
blob: e95c620897490ec65d43edf66686ddf01354eab3 (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
/* { dg-do compile } */
/* { dg-options "-O -fipa-sra" } */

struct A
{
  int *p;
  A() {p = (int *) -1;}
  ~A() {if (p && p != (int *) -1) *p = 0;}
};

struct B
{
  A a;
  char data[23];
  B() : a() {data[0] = 0;}
};

extern A ga;
extern int *gi;
extern void *gz;
extern B *gb;

static int * __attribute__ ((noinline)) foo (B *b, void *z)
{
  __builtin_memcpy (gz, z, 28);
  ga = b->a;
  return b->a.p;
}

int *bar (B *b, void *z)
{
  gb = b;
  return foo (b, z);
}