Merge from mainline
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / pr18178.C
blob9223e8323c0a82ff603fefa429c2a93e0d2e3b29
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-vrp1" } */
4 // Define this to see it work.
5 // #define WORK_WORK_WORK
7 #define THIRD
9 #ifdef THIRD
10 #define FIRST  i < 0 || 
11 #define ORIG int
12 #define CAST
13 #else
15 #define FIRST
16 #ifdef WORK_WORK_WORK
17 #define ORIG unsigned int
18 #define CAST
19 #else
20 #define ORIG int
21 #define CAST (unsigned)
22 #endif // WORK_WORK_WORK
24 #endif // THIRD
26 struct array
28   const ORIG len;
29   int *data;
32 extern void call (ORIG);
34 void doit (array *a)
36   for (ORIG i = 0; i < a->len; ++i)
37     {
38       if (FIRST  CAST (i) >= CAST (a->len))
39         throw 5;
40       call (a->data[i]);
41     }
44 /* VRP should remove all but 1 if() in the loop.  */
46 /* { dg-final { scan-tree-dump-times "if " 1 "vrp1"} } */
47 /* { dg-final { cleanup-tree-dump "vrp1" } } */