Make the MISRA addon emit extra warnings for unused arguments placed in
lines other than the function definition. This makes it easier for the
user to find violations.
The MISRA 2012 standard does not say anything about variadic functions
in the definition of rule 2.7. Therefore, these cases should be
considered as false positives.
* misra: Fix 8.2 false positives
Fix false positives in rule 8.2 that occurred in cases when we have a
function definition and declaration in the same file.
For example, the following code generated false positives before this
commit:
```
void f(uint8_t * const x);
void f(uint8_t * const x)
{ (void)x; }
```
We need to distinguish the declaration and the definition, so the dump
file generation routine was extended to keep token where the definition
of the function. The analysis in the addon also been improved.
Closes Trac issue: https://trac.cppcheck.net/ticket/10219
This fixes the crash on with struct fields containing unknown types
reported on the forum:
https://sourceforge.net/p/cppcheck/discussion/general/thread/d64551cc55/#5f0f
The suggested patch doesn't handle the cases when there are struct
fields with arrays containing unknown types. So the addon will not
generate warnings in these cases. The problem is that Cppcheck doesn't
generate valueType-pointer information for unknown types in the dump
file. When adding this in symboldatabase.cpp, MISRA addon will generate
a lot of false positives because we depend on the null value of
valueType.
So I suppose it better to left this as is, to don't break the addon for
such rare cases.
This commit allows to specify expected suppressions in the included
header files. This is necessary to verify MISRA checkers, which make
requirements for header files. For example, Rule 8.2 requires adding
prototypes for each function to the header files.
Fix false positives for the function calls with "const pointer to const
value" arguments: https://trac.cppcheck.net/ticket/9967.
The variable.valueType.constness have same encoding as encoding as
ValueType::constness in Cppcheck.
C89 standard defines enum members as enumeration contants at ch.
6.4.4.3, and they are always known at compile time.
This commit fix false positives for rule 18.8 (and possible other rules
that check "constentess") with enumeration members.
Fix Trac#9913
This commit add two additional cases for rule 20.3:
1. Support violations in the following format: `#include file.h`
2. Better multiline include directives and inline comments support.
See added test cases for examples.
Define different sets of reserved keywords for C90 and C99.
This will fix false negative for compliant example, defined in MISRA
document, and close trac 9506.
This commit will add feature to detect essential type categories
for operators of ternary operation.
This fixes issues with rule 10.1 and close the following ticket:
https://trac.cppcheck.net/ticket/9543
* misra.py: Allow executeCheck take multiple args
* misra.py: Fix R12.3 FN in variables declaration
Make rule 12.3 check detect commas in variables declaration code.
* Fix excluded lines
* Add support for global variables
* Fix FN when linenr from other file was excluded
* Add a few more tests
* Handle more cases
Handle additional cases to check commans in variables declaration
including:
* multiline variables declaration
* functions and structures initialized in the same line
* expanding macroses in initialization
* Fix FP in global struct initialization
* Add another test
* misra.py: R14.2: Verify for counter modification
Add additional check to detect modification of loop counter in loop
body. Related issue: https://trac.cppcheck.net/ticket/9490
Add small fix that treat all assignment operators defined in N1750
6.5.16 as has side affects. This will affects rules 13.1, 13.3, 13.5
and allow to catch some false negatives.
* Add tests for fixed FPs for R13.{1,5,6}
* fix
* use isAssignmentOp from cppcheck data
* remove unused set
* handle case with empty body or syntax error
* add test with outer variable
* Fix FP in nested loops, add tests
* Fix FP on outer variables
* Fixup false positives for not loop counters
Fixed usage of hasSideEffectsRecursive which was causes crashes
of rules 12.4 and 13.1.
Add more tests for these rules.
See trac ticket: https://trac.cppcheck.net/ticket/9487
Add some more tests for rule 10.1. They are given as examples in the
MISRA document. The 10.1 test that causes a false positive for 10.6 can be
found under the 10.6 tests.
Track ticket for false positive:
https://trac.cppcheck.net/ticket/9488
Trac ticket for the false negative:
https://trac.cppcheck.net/ticket/9489
The unused argument causes the new check for rule 2.7 to output an error
here.
I verified that the regression test still works without the unused
argument (misra.py would still crash).
Travis should be happy again.
* Add check for MISRA-C 2012 Rule 2.7 and test cases.
* Cast unused function parameters of some test patterns to "void".
* Fix function parameter void cast in "misra_17_6". Add comment to "misra_11_7_extra" to make all function parameter void casts look alike.
Rule 21.1 now doesn't report errors on usage of library functions
started from underscore (e.g. `_exit') and valid errno assignment.
See added tests for examples.
Fix R16.3 state machine which doesn't report errors in last case/default
statemenet. See added tests for examples.
Issue on trac: https://trac.cppcheck.net/ticket/8548