Add output of the received and expected types for messages that indicate type differences
With the MISRA 2012 "essential type" implementation, we often see messages that indicated "Expression assigned to a narrower or different essential type" or "Composite expression with smaller essential type than other operand". For these types of messages that indicate a discrepancy of type, it would help in debugging these messages if the types involved could be added into the output.
-
Current versions of PC-lint Plus include MISRA essential type information in such messages. For example:
int f(int a, short b) {
return (b + b) + (a + b);
}resulted in the message:
Note 9032: Composite expression with smaller essential type than other operand
with PC-lint 9 but in PC-lint Plus the same message is rendered as:
note 9032: left operand to + is a composite expression of type 'signed16' which is smaller than the right operand of type 'signed32'
and points the the appropriate location. PC-lint Plus also provides the ability to see the step-by-step essential type evaluation which can be useful when trying to understand the essential types involved in complex expressions. This feature can be enabled using the +f12 option and enabling message 9903. For the above example, this produces:
note 9903: (signed16 + signed16) + (signed32 + signed16)
note 9903: (signed16) + (signed32)
note 9903: signed32 -
Robert Slaymaker commented
Definitely gets my vote--this would be quite helpful when linting macro-based code or complex expressions after they're written.
-
Carl commented
I've also wished for a similar enhancement to some older , non-Misra related messages. It seems now like many of them do. I don't know if this has been addressed in the older messages since I first thought of it.