summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tree-ssa/pr18178.C
blob: 9223e8323c0a82ff603fefa429c2a93e0d2e3b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1" } */

// Define this to see it work.
// #define WORK_WORK_WORK

#define THIRD

#ifdef THIRD
#define FIRST  i < 0 || 
#define ORIG int
#define CAST
#else

#define FIRST
#ifdef WORK_WORK_WORK
#define ORIG unsigned int
#define CAST
#else
#define ORIG int
#define CAST (unsigned)
#endif // WORK_WORK_WORK

#endif // THIRD

struct array
{
  const ORIG len;
  int *data;
};

extern void call (ORIG);

void doit (array *a)
{
  for (ORIG i = 0; i < a->len; ++i)
    {
      if (FIRST  CAST (i) >= CAST (a->len))
	throw 5;
      call (a->data[i]);
    }
}

/* VRP should remove all but 1 if() in the loop.  */

/* { dg-final { scan-tree-dump-times "if " 1 "vrp1"} } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */