summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c
blob: 16014bb15c5299d3a7ddef8d84e817b1004e2452 (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
/* { dg-do compile } */
/* { dg-options "-O2 -Wstrict-overflow" } */

unsigned int
do_scrolling (unsigned int window_size, unsigned int writecost)
{
  unsigned int i = window_size;

  int terminal_window_p = 0;
  unsigned int queue = 0;

  for (i = window_size; i; i--)
    {
      if (writecost < i)
    ++queue;
      else if (writecost & 1)
    terminal_window_p = 1;
    }

  if (queue > 0)
    {
      if (!terminal_window_p)
    {
      terminal_window_p = 1;
    }
    }

  if (terminal_window_p)
    return 100;
  return 0;
}