SWITCH-missing-enum-val
In this section:
Synopsis
A switch case uses only a subset of an enumeration.
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
A switch case uses only a subset of an enumeration.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
enum ABC { A, B, C};
int example(enum ABC v) {
switch (v) { /* Not compliant, C not used.*/
case A: return 1;
case B: return 2;
default: return -1;
}
}
The following code example passes the check and will not give a warning about this issue:
enum ABC { A, B };
int example(enum ABC v) {
switch (v) { /* Compliant */
case A: return 1;
case B: return 2;
default: return -1;
}
}