Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-ccp-21.c
blob3f4adf434833f477e299d96194b7e788a221f8ed
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdump-tree-ccp1" } */
4 struct A {
5 struct B {
6 int i;
7 } b;
8 } a;
10 int foo (void)
12 struct B *p = &a.b;
13 struct A *q = (struct A *) p;
14 return q->b.i;
17 int bar (void)
19 struct A *p = &a;
20 struct B *q = (struct B *) p;
21 return q->i;
24 /* The first access is through struct A, so a.b.i is fine,
25 the second access needs to preserve the original access type struct B. */
27 /* { dg-final { scan-tree-dump-times "a.b.i" 1 "ccp1" } } */
28 /* { dg-final { scan-tree-dump-times "MEM\\\[\\\(struct B \\\*\\\)&a\\\].i" 1 "ccp1" } } */
29 /* { dg-final { cleanup-tree-dump "ccp1" } } */