2017-09-26 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr53265.c
blobd6418228c3bc63a08931967104afced19ff9b94c
1 /* PR tree-optimization/53265 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wall" } */
4 /* { dg-require-effective-target size32plus } */
6 void bar (void *);
7 int baz (int);
9 void
10 fn1 (void)
12 unsigned int a[128];
13 int i;
15 for (i = 0; i < 128; ++i) /* { dg-message "note: within this loop" } */
16 a[i] = i * 0x02000001; /* { dg-warning "64 invokes undefined behavior" } */
17 bar (a);
20 void
21 fn2 (void)
23 unsigned long long a[128];
24 int i;
26 for (i = 0; i < 128; i++) /* { dg-message "note: within this loop" } */
27 a[i] = (i + 1LL) * 0x0123456789ABCDEFLL; /* { dg-warning "112 invokes undefined behavior" } */
28 bar (a);
31 void
32 fn3 (void)
34 unsigned char a[16], b[16], c[16];
35 int i;
37 bar (b);
38 for (i = 0; i < (int) (sizeof (a) / sizeof (a[0])); i++) /* { dg-message "note: within this loop" } */
40 c[i + 8] = b[i]; /* { dg-warning "8 invokes undefined behavior" } */
41 a[i + 8] = b[i + 8];
43 bar (a);
44 bar (c);
47 void
48 fn4 (void)
50 unsigned int *a[32], *o, i;
52 bar (a);
53 for (i = 0; i <= sizeof (a) / sizeof (a[0]); i++) /* { dg-message "note: within this loop" } */
55 o = a[i]; /* { dg-warning "32 invokes undefined behavior" } */
56 bar (o);
60 void
61 fn5 (void)
63 unsigned short a[23940];
64 unsigned int b[1140];
65 int j;
67 bar (b);
68 for (j = 0; j < 1140; j++) /* { dg-message "note: within this loop" } */
69 a[23940 + j - 950] = b[j]; /* { dg-warning "950 invokes undefined behavior" } */
70 bar (a);
73 void
74 fn6 (void)
76 double a[4][3], b[12];
77 int i;
78 bar (b);
79 for (i = 0; i < 12; i++) /* { dg-message "note: within this loop" } */
80 a[0][i] = b[i] / 10000.0; /* { dg-warning "3 invokes undefined behavior" } */
81 bar (a);
84 void
85 fn7 (void)
87 int a[16], b, c;
88 bar (a);
89 for (b = a[c = 0]; c < 16; b = a[++c])
90 /* { dg-warning "15 invokes undefined behavior" "" { target *-*-* } .-1 } */
91 /* { dg-message "note: within this loop" "" { target *-*-* } .-2 } */
92 baz (b);
96 const void *va, *vb, *vc, *vd, *ve;
97 const void *vf[4];
98 void
99 fn8 (void)
101 unsigned long i;
102 vf[0] = va; vf[1] = vb; vf[2] = vc; vf[3] = vd;
103 for (i = 0; i < (sizeof (vf) / sizeof (vf[0])); i++)
104 if (!vf[i])
105 vf[i] = ve;
108 int wa, wb[53][5], wc[53][5];
110 void
111 fn9 (void)
113 int i, j, k;
114 for (i = 0; i < 53; i++)
115 for (j = 16 / (((wa & 1) != 0) ? 8 : 4); j > 0; j--)
117 int d = 1;
118 if (wb[i][j] == 0 || wc[i][1] != 0)
119 continue;
120 for (k = 0; k < j; k++)
121 if (wc[i + k][1])
123 d = 0;
124 break;
126 if (!d)
127 continue;
128 wc[i][j] = baz (0);
132 int xa[18];
134 void
135 fn10 (void)
137 int i;
138 for (i = 16; i < 32; i++) /* { dg-message "note: within this loop" } */
139 xa[i] = 26; /* { dg-warning "2 invokes undefined behavior" } */
142 __attribute__((noinline)) static void
143 fn11 (int x)
145 int i = 1;
146 if (x > 1)
148 baz (i);
149 while (++i != x); /* { dg-bogus "invokes undefined behavior" } */
152 void
153 fn12 (void)
155 fn11 (1);
156 fn11 (1);
157 fn11 (1);