OSDN Git Service

PR c/36507
[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 struct c { unsigned int a; unsigned int b; };
8 extern void bar (struct c *);
9 int
10 foo (struct c *p)
11 {
12   int i;
13   int sum = 0;
14
15   for (i = 0; i < p->a - p->b; ++i)
16     {
17       if (i > 0)
18         sum += 2;
19       bar (p);
20     }
21   return sum;
22 }