summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr13146.C
blob: 22baf03d33b3edb7cbb65d13a37e7a8a47ac14c7 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* { dg-do link } */
/* { dg-options "-O -fstrict-aliasing" } */

class first
{
public:
  double d;
  int f1;
};

class middle : public first
{
};

class second : public middle
{
public:
  int f2;
  short a;
};

class third
{
public:
  char a;
  char b;
};

class multi: public third, public second
{
public:
  short s;
  /* The following field used to be of type char but that causes
     class multi to effectively get alias-set zero which we end
     up not optimizing because of the fix for PR44164.  */
  int f3;
};

extern void link_error ();

void
foo (first *s1, second *s2)
{
  s1->f1 = 0;
  s2->f2 = 0;
  s1->f1++;
  s2->f2++;
  s1->f1++;
  s2->f2++;
  if (s1->f1 != 2)
    link_error ();
}

void
bar (first *s1, multi *s3)
{
  s1->f1 = 0;
  s3->f3 = 0;
  s1->f1++;
  s3->f3++;
  s1->f1++;
  s3->f3++;
  if (s1->f1 != 2)
    link_error ();
}


int
main()
{
  first a;
  second b;
  multi c;
  foo (&a, &b);
  bar (&a, &c);
  return 0;
}