When I enable MISRA rules check for the C/C++ compiler for MSP430 I get the MISRA warning 10.1/R for the following code.
typedef enum _MyEnum { One, Two } MyEnum;
MyEnum MyVariable;
int foo(void)
{
int result = 1;
if (One == MyVariable) // fails here with MISRA-C:2004 10.1/R
{
result = 2;
}
return result;
}
Our coding style convention requires that the variable is at the right hand side. Therefore I don't want to swap One and MyVariable, although that makes the warning to disappear.
Is that a bug in the MISRA checker? If not, why is the comparison of two terms not commutable?