aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-20.c
blob: bc0cd0fe58014e7ad0e7df57eb6df29c466c786d (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
/* PR c/7652 */
/* { dg-do compile } */
/* { dg-options "-Wimplicit-fallthrough" } */

int
f (int i)
{
  switch (i)
    {
    case -1:
      __attribute__((fallthrough));
    default:
      __attribute__((fallthrough));
    case 1:
      return 6;
    case 2 ... 4:
      __attribute__((fallthrough));
    case 5:
      return 7;
    }
  return 0;
}

int
g (int i)
{
  switch (i)
    {
    case -1:
      __attribute__((used)); /* { dg-warning "empty declaration|ignored" } */
    default:
      __attribute__((used)); /* { dg-warning "empty declaration|ignored" } */
    case 1:
      return 6;
    case 2 ... 4:
      __attribute__((used)); /* { dg-warning "empty declaration|ignored" } */
    case 5:
      return 7;
    }
  return 0;
}