Merge from trunk @ 138209
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstrict-aliasing-bogus-ref-all.c
blob7e8d1771568d532639b31ad153e60ddc8d8a4476
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wall" } */
4 struct g { long a; };
5 unsigned long f(struct g *a) { return *(unsigned long *)&a->a; }
7 struct A
9 void *a;
12 int g(const struct A *x, long *y)
14 typedef long __attribute__ ((may_alias)) long_a;
15 *y = *(const long_a *) (&x->a);
16 return 1;
19 void *a;
21 int
22 f0 (long *y)
24 *y = *(const long *) &a; /* { dg-warning "will break" } */
25 return 1;
28 int
29 f1 (long *y)
31 typedef long __attribute__ ((may_alias)) long_a;
32 *y = *(const long_a *) &a;
33 return 1;
36 int
37 f2 (long *y)
39 *y = *(const long *) &a; /* { dg-warning "will break" } */
40 return 1;