diff options
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wswitch-3.C | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wswitch-3.C b/gcc/testsuite/g++.dg/warn/Wswitch-3.C new file mode 100644 index 00000000000..df1f8956dad --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wswitch-3.C @@ -0,0 +1,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; +} |