OSDN Git Service

* gcc.dg/simulate-thread/simulate-thread.gdb: Call
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / Wstrict-overflow-18.c
1 /* { dg-do compile } */
2 /* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
3
4 /* Don't warn about an overflow when folding i > 0.  The loop analysis
5    should determine that i does not wrap.
6
7    The test is really bogus, p->a - p->b can be larger than INT_MAX
8    and thus i can very well wrap.  */
9
10 struct c { unsigned int a; unsigned int b; };
11 extern void bar (struct c *);
12 int
13 foo (struct c *p)
14 {
15   int i;
16   int sum = 0;
17
18   for (i = 0; i < p->a - p->b; ++i)
19     {
20       if (i > 0)  /* { dg-bogus "warning" "" { xfail *-*-* } } */
21         sum += 2;
22       bar (p);
23     }
24   return sum;
25 }