Hi all!
I’m interested in developing a clang static checker for enum comparison in switch and throwing a warning.
I found out that it already exists in if comparison in clang but my question is:
Is this on purpose that different enum types don’t send warning or int and enum comparison in switches but send in if?
Example:
enum MIXED_ENUMS_e { E1, E2 };
enum MIXED_ENUMS_f { F0, F1, F2, F3 };
void mixed_enums(MIXED_ENUMS_e ee)
{
int x;
switch (ee)
{
case E1: x = 1; break;
case F1: x = 2; break; // TODO warning: ee and F1 have different types.
}
switch (x)
{
case E1: ++x; break; // TODO warning: x and E1 have different types.
case F3: --x; break; // TODO warning: x and F3 have different types.
}
if (ee == F0) {} // Already exsisting warning: ee and F0 have different types.
**if** (ee == x) {}<i> // Already exsisting warning: ee and x have different types.
</i>}
BR Alex.