summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wswitch-3.C
blob: df1f8956dadd35cc314dac2131f0693e221a9ac6 (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
/* { dg-do compile } */
/* { dg-options "-Wswitch" } */

enum E { A, B, C, D, E, F };

int
f1 (enum E e)
{
  switch (e)
    {
    case A: return 1;
    case B: return 2;
    case C: return 3;
    case D: return 4;
    case E: return 5;
    case F: return 6;
    case 7: return 7;	/* { dg-warning "not in enumerated type" } */
    }
  return 0;
}

int
f2 (enum E e)
{
  switch (e)
    {
    case A: return 1;
    case B: return 2;
    case C: return 3;
    case D: return 4;
    case E: return 5;
    case F: return 6;
    case 7: return 7;	/* { dg-warning "not in enumerated type" } */
    default: return 8;
    }
  return 0;
}