summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-36.c
blob: 1821e48b92869df50267f003f8e51d5938246029 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* PR c/79153 */
/* { dg-do compile } */
/* { dg-options "-Wimplicit-fallthrough" } */

int
test (int v1, int v2)
{
  switch (v1)
    {
    case 3:
      switch (v2)	/* { dg-warning "this statement may fall through" } */
	{
	case 1:
	  return 28;
	case 2:
	  return 38;
	case 3:
	  return 88;
	default:
	  break;
	}
    case 4:		/* { dg-message "here" } */
      return 168;
    case 5:
      switch (v2)	/* { dg-warning "this statement may fall through" } */
	{
	case 4:
	  break;
	case 5:
	  return 38;
	case 6:
	  return 88;
	}
    case 6:		/* { dg-message "here" } */
      return 169;
    case 7:
      switch (v2)	/* { dg-warning "this statement may fall through" } */
	{
	case 7:
	  return 38;
	case 8:
	  return 88;
	}
    case 8:		/* { dg-message "here" } */
      return 170;
    case 9:
      switch (v2)	/* { dg-bogus "this statement may fall through" } */
	{
	case 9:
	  return 38;
	case 10:
	  return 88;
	default:
	  return 89;
	}
    case 10:
      return 171;
    case 11:
      switch (v2)	/* { dg-bogus "this statement may fall through" } */
	{
	case -__INT_MAX__ - 1 ... 31:
	  return 38;
	case 32:
	  return 88;
	case 33 ... __INT_MAX__:
	  return 89;
	}
    case 12:
      return 172;
    }
  return -1;
}