In the cppcheck source, checkbool.cpp::isBool(), the values of "bool" and "_Bool" (from C99) are evaluated.
In misra.py, isBoolExpression() only checks for "bool". It should also check for "_Bool" for consistency.
Both places check for "true" and "false" so that is consistent with stdbool.h usage added for C99.
Since MISRA is heavily used by the AUTOSAR standard, they are some additional extended definitions that would be useful to add in the .cpp and .py checks. AUTOSAR adds Platform_Types.h which defines: "boolean", "TRUE", and "FALSE". Could these be added for the next release?
Cheers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In misra.py, isBoolExpression() only checks for "bool". It should also check for "_Bool" for consistency.
yes. well to be accurate the misra addon could check if c99 is enabled. (it should be enabled by default I think).
do you think you could create a pull request on github? please add some test cases in cppcheck/addons/test/misra-test.c and update the cppcheck/addons/misra.py file?
Could these be added for the next release?
I am not accepting further improvements now for 1.85. We are trying to improve the robustness right now. But for 1.86 it's possible.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the cppcheck source, checkbool.cpp::isBool(), the values of "bool" and "_Bool" (from C99) are evaluated.
In misra.py, isBoolExpression() only checks for "bool". It should also check for "_Bool" for consistency.
Both places check for "true" and "false" so that is consistent with stdbool.h usage added for C99.
Since MISRA is heavily used by the AUTOSAR standard, they are some additional extended definitions that would be useful to add in the .cpp and .py checks. AUTOSAR adds Platform_Types.h which defines: "boolean", "TRUE", and "FALSE". Could these be added for the next release?
Cheers.
yes. well to be accurate the misra addon could check if c99 is enabled. (it should be enabled by default I think).
do you think you could create a pull request on github? please add some test cases in cppcheck/addons/test/misra-test.c and update the cppcheck/addons/misra.py file?
I am not accepting further improvements now for 1.85. We are trying to improve the robustness right now. But for 1.86 it's possible.