/* >>>------------------------------------------------------------ * * File: rule_12.6.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 12.6 (Advisory): * The operands of logical operators (&&, || and !) should be * effectively Boolean. Expressions that are effectively Boolean * should not be used as operands to operators other than (&&, ||, !, * =, ==, != and ?:). * * Implemented by messages: * 3322 Operand of a logical ! operator is a constant expression * which is not a 'Boolean' value. * * 3377 Operand of a logical && or || operator is a constant * expression which is not a 'Boolean' value. * * 4101 Both operands of & operator are 'Boolean' expressions. * * 4102 Both operands of | operator are 'Boolean' expressions. * * 4103 Both operands of arithmetic or bitwise operator are * 'Boolean' expressions. * * 4104 Left hand operand of arithmetic or bitwise operator is a * 'Boolean' expression. * * 4105 Right hand operand of arithmetic or bitwise operator is * a 'Boolean' expression. * * 4106 Both operands of && operator are arithmetic or bitwise * expressions. * * 4107 Both operands of || operator are arithmetic or bitwise * expressions. * * 4108 Left hand operand of logical operator is an arithmetic * or bitwise expression. * * 4109 Right hand operand of logical operator is an arithmetic * or bitwise expression. * * 4110 Operand of ! operator is an arithmetic or bitwise * expression. * * 4111 Right hand operand of relational operator is a 'Boolean' * expression. * * 4112 Left hand operand of relational operator is a 'Boolean' * expression. * * 4113 Both operands of relational operator are 'Boolean' * expressions. * * 4114 Operand of ~ operator is a 'Boolean' expression. * * 4115 Operand of logical && or || operator is not an * 'essentially Boolean' expression. * * 4116 Operand of logical ! operator is not an 'essentially * Boolean' expression. * * <<<------------------------------------------------------------ */ /* PRQA S 2982 ++ */ #include "misra.h" #include "m2cmex.h" extern S16 test_1206( void ) { s16r = ( s16a < s16b ) & ( s16c > s16d ); /* MISRA Violation */ s16r = ( s16a < s16b ) | ( s16c > s16d ); /* MISRA Violation */ s16r = ( s16c > s16d) * (s16a < s16b); /* MISRA Violation */ s16r = ( s16c > s16d) + s16b; /* MISRA Violation */ s16r = s16r + (s16c > s16d); /* MISRA Violation */ bla = ( s16a + s16b ) && ( s16c + s16d ); /* MISRA Violation */ bla = ( s16a + s16b ) || ( s16c + s16d ); /* MISRA Violation */ bla = ( s16a + s16b ) && ( s16c > s16d ); /* MISRA Violation */ bla = ( s16a > s16b ) && ( s16c + s16d ); /* MISRA Violation */ bla = ! ( s16a + s16b ); /* MISRA Violation */ bla = (s16a + s16b) > (s16c > s16d); /* MISRA Violation */ bla = (s16a > s16b) > (s16c + s16d); /* MISRA Violation */ bla = (s16a > s16b) > (s16c > s16d); /* MISRA Violation */ s16r = ~(s16a > s16b); /* MISRA Violation */ bla = s16a && ( s16c < s16d ); /* MISRA Violation */ bla = !s16a; /* MISRA Violation */ return s16r; }