03-10-2012, 09:26 AM
The expression resulting from the expansion of BAR(FOO(2U)) is a constant expression with the value 4 and type unsigned int. According to Section 6.10.4 of the MISRA C Guidelines, the underlying type of the expression is unsigned char, being the smallest unsigned type that can represent the value 4. Further, according the Section 6.10.5, constant expressions are not complex expressions.
Rule 10.1(a) will be broken if the type of the object REGACESSMAKRO is either smaller than unsigned char, or is a signed type. Similarly, Rule 10.1(a) will be broken if either of these is true for the type CAST_TO_REGISTER_SIZE. Since the types are not specified in the example, it is not possible to say for sure.
Rule 10.1(b) should never be broken in this example because the expression on the right-hand side of the assignment is not composite. This appears to be the part of the rule your checking tool identifies as being broken so it would seem that it is not performing the check correctly.
Note: the example code has some missing ) and a missing ; but it was clear where these should have been so their omission doesn't affect the answer given here.
Rule 10.1(a) will be broken if the type of the object REGACESSMAKRO is either smaller than unsigned char, or is a signed type. Similarly, Rule 10.1(a) will be broken if either of these is true for the type CAST_TO_REGISTER_SIZE. Since the types are not specified in the example, it is not possible to say for sure.
Rule 10.1(b) should never be broken in this example because the expression on the right-hand side of the assignment is not composite. This appears to be the part of the rule your checking tool identifies as being broken so it would seem that it is not performing the check correctly.
Note: the example code has some missing ) and a missing ; but it was clear where these should have been so their omission doesn't affect the answer given here.
Posted by and on behalf of the MISRA C Working Group