2010-05-26 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / pr13146.C
blob22baf03d33b3edb7cbb65d13a37e7a8a47ac14c7
1 /* { dg-do link } */
2 /* { dg-options "-O -fstrict-aliasing" } */
4 class first
6 public:
7   double d;
8   int f1;
9 };
11 class middle : public first
15 class second : public middle
17 public:
18   int f2;
19   short a;
22 class third
24 public:
25   char a;
26   char b;
29 class multi: public third, public second
31 public:
32   short s;
33   /* The following field used to be of type char but that causes
34      class multi to effectively get alias-set zero which we end
35      up not optimizing because of the fix for PR44164.  */
36   int f3;
39 extern void link_error ();
41 void
42 foo (first *s1, second *s2)
44   s1->f1 = 0;
45   s2->f2 = 0;
46   s1->f1++;
47   s2->f2++;
48   s1->f1++;
49   s2->f2++;
50   if (s1->f1 != 2)
51     link_error ();
54 void
55 bar (first *s1, multi *s3)
57   s1->f1 = 0;
58   s3->f3 = 0;
59   s1->f1++;
60   s3->f3++;
61   s1->f1++;
62   s3->f3++;
63   if (s1->f1 != 2)
64     link_error ();
68 int
69 main()
71   first a;
72   second b;
73   multi c;
74   foo (&a, &b);
75   bar (&a, &c);
76   return 0;