aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2y-switch-3.c
blob: 3cb143a42ead29b43d6ed706682a38a6cd15bb78 (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
/* C2Y N3370 - Case range expressions.  */
/* { dg-do run } */
/* { dg-options "-std=c2y -pedantic-errors" } */

extern void abort ();

void
foo (int x)
{
  switch (x)
    {
    case -42 ... 42:
      if (x < -42 || x > 42)
        abort ();
      break;
    case 43 ... 43:
      if (x != 43)
        abort ();
      break;
    case 44:
      if (x != 44)
        abort ();
      break;
    case 45 ... 46:
      if (x < 45 || x > 46)
        abort ();
      break;
    default:
      if (x >= -42 && x <= 46)
        abort ();
      break;
    }
}

int
main ()
{
  for (int i = -44; i <= 48; ++i)
    foo (i);
}