Commit Graph

188 Commits

Author SHA1 Message Date
Daniel Marjamäki c120c59912 Fixed #10446 (FP: misra-c2012-10.1 (u8 & 0x42U)) 2021-09-12 08:56:07 +02:00
Daniel Marjamäki 055d111ee9 Revert "misra.py: Fixed FN for rule 21.8"
This reverts commit 870b8b9c60.
2021-08-30 19:50:36 +02:00
orbitcowboy 870b8b9c60 misra.py: Fixed FN for rule 21.8 2021-08-30 11:07:38 +02:00
Daniel Marjamäki e1d0db38ee Fixed #10380 (FP: misra-c2012-20.9) 2021-08-22 21:13:27 +02:00
Daniel Marjamäki 0662c94d83 misra: implement rule 21.20 2021-08-22 07:38:07 +02:00
Daniel Marjamäki 6e4acbd3bc misra: implement rule 21.19 2021-08-19 06:58:49 +02:00
Daniel Marjamäki 8700d1b86d update misra test 2021-08-16 20:46:37 +02:00
Daniel Marjamäki 864d6462d0 misra: implement rule 21.16 2021-08-15 20:50:20 +02:00
Daniel Marjamäki 8d67653de3 misra: implement rule 21.14 2021-08-15 19:23:51 +02:00
Daniel Marjamäki 682c4510a9 misra: implement rule 1.4 2021-08-15 13:39:14 +02:00
Daniel Marjamäki 6ddb8388ed misra: implement rule 21.21 2021-08-15 13:38:04 +02:00
Daniel Marjamäki 10c2dcf721 misra: implement rule 22.7 2021-08-15 12:04:55 +02:00
Daniel Marjamäki b3034a5628 misra: implement rule 22.9 2021-08-15 07:46:32 +02:00
Daniel Marjamäki 5313a40c3b misra; implement rule 22.8 2021-08-14 19:24:31 +02:00
Daniel Marjamäki 4b126db9ca misra: implement rule 22.10 2021-08-13 18:03:37 +02:00
Daniel Marjamäki f85f3c28e1 misra; implement rule 21.15 2021-07-30 15:53:10 +02:00
Daniel Marjamäki 4baf221a6b misra; implemented rule 21.2 2021-07-22 20:39:04 +02:00
Daniel Marjamäki 388b7a0fae misra; implemented rule 20.12 2021-07-22 19:51:31 +02:00
Daniel Marjamäki a65fa9b682 misra; implement rule 20.11 2021-07-22 16:11:25 +02:00
Daniel Marjamäki 3ba4696f4f misra; implement rule 20.9 2021-07-22 12:08:51 +02:00
Daniel Marjamäki 74ab8f1a48 misra; implemented rule 20.8 2021-07-22 08:46:28 +02:00
Daniel Marjamäki d2843b70ca misra; implement rule 10.7 2021-07-21 19:18:12 +02:00
Daniel Marjamäki fb8d6daf79 misra; implement rule 10.5 2021-07-21 15:25:01 +02:00
Daniel Marjamäki f5fe562050 misra; improved checking of 10.3 2021-07-21 10:56:17 +02:00
Daniel Marjamäki 4428efbd2b misra; improved essential type for composite expressions 2021-07-21 08:20:15 +02:00
Daniel Marjamäki b409d4a598 misra; implement rule 16.1 2021-07-20 20:40:42 +02:00
Daniel Marjamäki e72e59f934 misra; implement rule 12.4 2021-07-20 19:50:31 +02:00
Daniel Marjamäki 937146127a misra; fix essential type for integer literals 2021-07-20 18:27:49 +02:00
Daniel Marjamäki b320a092d0 misra; fix essential type for char literals 2021-07-20 16:39:59 +02:00
Daniel Marjamäki 6f7722873e CI; specify unix64 platform when running misra-test 2021-07-20 12:23:16 +02:00
Daniel Marjamäki d467505696 misra; update essential type for variables 2021-07-19 17:12:24 +02:00
Daniel Marjamäki 657d530fa1 misra; implement rule 10.3 2021-07-19 14:54:17 +02:00
Daniel Marjamäki d1fe34e167 misra; implement rule 8.10 2021-07-18 21:18:07 +02:00
Daniel Marjamäki 5f548a4b6c misra; implement rule 8.9 2021-07-18 10:31:52 +02:00
Daniel Marjamäki 59c797c776 misra; implement rule 8.8 2021-07-17 23:38:29 +02:00
Daniel Marjamäki f44a82856f misra; implement rule 8.7 2021-07-17 22:36:03 +02:00
Daniel Marjamäki 77d8b714ea misra; implement rule 8.6 2021-07-17 21:24:53 +02:00
Daniel Marjamäki aa910d3c38 misra; implemented rule 8.5 2021-07-17 19:59:21 +02:00
Daniel Marjamäki e4ae4471e8 misra; implement rule 11.2 2021-07-11 20:55:54 +02:00
Daniel Marjamäki 9d5c65fcce CI; Improved testing of misra addon 2021-07-11 17:24:14 +02:00
Daniel Marjamäki 754d648b0f misra; implement rule 11.1 2021-07-11 07:50:13 +02:00
Daniel Marjamäki 009c144455 misra; implement rule 8.4 2021-07-10 20:10:44 +02:00
Daniel Marjamäki 599a559351 misra; implement rule 5.9 2021-07-10 12:51:40 +02:00
Daniel Marjamäki c77235f12c misra; implement rule 5.8 2021-07-09 09:47:23 +02:00
Daniel Marjamäki e05a9d7e65 misra: implement rule 2.5 2021-07-08 22:03:27 +02:00
Daniel Marjamäki 4ecf3ccd17 misra: implement rule 22.5 2021-07-07 23:00:12 +02:00
Daniel Marjamäki cf049cb759 misra: implement rule 5.7 2021-07-07 21:47:17 +02:00
Daniel Marjamäki 859e541661 misra: implement rule 2.4 2021-07-07 20:30:52 +02:00
Daniel Marjamäki 13d55c7060 misra; implement rule 2.3 2021-07-07 15:16:53 +02:00
Daniel Marjamäki 00a9671f46 misra: implement 8.1 2021-07-07 13:34:55 +02:00
Daniel Marjamäki 9172f2ab3b addons; add CTU infrastructure 2021-07-07 10:58:13 +02:00
Georgiy Komarov 6f389014f1
cppcheckdata: Fix crash on an empty union (#3326) 2021-07-06 17:01:58 +02:00
Georgiy Komarov 426117a30d
misra: Improve warning messages for rule 8.2 when the missing arguments are on the next line (#3320)
This makes it easier for the user to find the violation.

Suggested in the forum: https://sourceforge.net/p/cppcheck/discussion/development/thread/801dc07e59/#a1a8/d3e9/c455/8915/747c/2525/0eb8/0f7d
2021-07-01 21:08:40 +02:00
Georgiy Komarov 10123b4ad2
misra: Emit more accurate warnings for unused arguments in rule 2.7 (#3314)
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.
2021-06-29 11:17:38 +02:00
Georgiy Komarov a2cb9f17c1
misra: Don't consider variadic arguments as the violation of rule 2.7 (#3315)
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.
2021-06-29 08:46:35 +02:00
Georgiy Komarov 62dbe2eb2f
misra: Fix false positives for rule 8.2 (#3311)
Reported in the forum: https://sourceforge.net/p/cppcheck/discussion/development/thread/801dc07e59/?page=1&limit=25#a1a8
2021-06-27 22:57:50 +02:00
Georgiy Komarov b89f5fbeff
misra: Fix 8.2 false positives (#3309)
* 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
2021-06-27 10:51:32 +02:00
Georgiy Komarov 452c92494e
misra: Fix 8.2 false positives (#3306)
Type declaration on the next line is not allowed in rule 8.2. But we
need to make sure that the files of the checked files are the same.

Reported on the forum: https://sourceforge.net/p/cppcheck/discussion/development/thread/801dc07e59/#32c3/e90b/293e/39df/85b3/b821/e0c3
2021-06-25 16:06:29 +02:00
Georgiy Komarov 79f59d8f39
misra: Fixed crash with struct fields with unknown types on 9.x rules (#3305)
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.
2021-06-24 08:29:27 +02:00
Ivar Andreas Bonsaksen e3b7ceec7e
Fix issue where misra 9_x evaluation crashes on some undefined structs with nested initialisers (#3290) 2021-06-04 17:19:40 +02:00
Georgiy Komarov 7a009fece0
misra: Add support for expected suppressions in header files in `-verify` mode (#3252)
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.
2021-05-08 10:27:31 +02:00
Daniel Marjamäki f7d0bf7a59 Refactoring; Reuse simplecpp::characterLiteralToLL 2021-05-02 13:44:37 +02:00
Georgiy Komarov e1bfd369db
misra: Fix false positives for rule 7.3 (#3236)
Fix false positives for the identifiers that contain 'ul' in their names.

Reported on the forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/c326538221/
2021-04-27 19:42:34 +02:00
Georgiy Komarov fce3db8b7d
misra: Fixed a crash in rule 8.2 (#3208)
Due to incorrect indentation, we return "None" instead of an empty list,
which causes the crash.

The problem was reported on the forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/e146b8d779/
2021-04-13 10:09:42 +02:00
Paul Fultz II 5077663684
Fix issue 9979: false positive: containerOutOfBounds with conditional resize (#3136) 2021-03-30 14:02:28 +02:00
Lars Even Almaas 9786f1c34b
Suggested implementation for rule 8.2 (#3169) 2021-03-25 08:25:43 +01:00
Georgiy Komarov 390a5af064
misra.py: Fix crashes on obsolete GCC syntax for struct initialization (#3175)
* misra.py: Fix crashes on obsolete GCC syntax for struct initialization

* Added expected violations
2021-03-20 13:59:39 +01:00
Daniel Marjamäki ebf54ac53e Misra; Remove 12.4 because the check is not implemented properly 2021-02-25 22:11:13 +01:00
Georgiy Komarov 82f51bd523
misra: Fix crash on rule 9.x (#3024)
Closes ticket #10084
2021-01-07 15:04:12 +01:00
kskjerve d4860f500a
MISRA 9.2 to 9.5 (#2954) 2020-12-16 17:28:54 +01:00
Ivar Andreas Bonsaksen 9029fff59d
Fixed #9993 (false positive: misra-c2012-9.2) (#2908) 2020-11-18 10:50:35 +01:00
Ivar Andreas Bonsaksen 0e7ec1eddf
Fixed #9988 (false positive: misra-c2012-9.2) (#2904) 2020-11-16 17:31:00 +01:00
kskjerve 4d3f76b63c
MISRA rule 9.2 The initializer for an aggregate or union shall be enclosed in braces (#2899) 2020-11-16 09:27:17 +01:00
Lars Even Almaas 3a91b998d6
MISRA rule 10.2 Expressions of essentially character type in additions and subtraction (#2897) 2020-11-12 11:37:28 +01:00
Daniel Marjamäki 2ae91b9ffe Try to fix addon suppressions tests 2020-11-11 20:28:26 +01:00
Lars Even Almaas 9d70926fcd
MISRA rule 15.4 Only one break/goto from iteration statement (#2892) 2020-11-09 15:11:08 +01:00
Georgy Komarov 9cbb09076c
misra.py: Fix R7.2 crash on va_args (#2886) 2020-11-05 23:54:12 +01:00
Lars Even Almaas c1212f823f
MISRA rule 7.2 Require 'u' prefix when using large unsigned integer constants (#2881) 2020-11-05 13:38:09 +01:00
Georgy Komarov 6f7f508967
misra.py: Fix 7.4 false positive (#2883)
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.
2020-11-05 08:13:23 +01:00
Lars Even Almaas 05b804d126
MISRA Rule 7.4 Check if variables assigned as string literals are const (#2866) 2020-11-04 13:45:02 +01:00
Georgy Komarov b87aaaac52
Fix and impove MISRA 6.1 and 6.2 rules (#2863) 2020-10-28 20:54:43 +01:00
Lars Even Almaas 79b9dd5345
MISRA Rule 6.1/6.2 Bit field check (#2861) 2020-10-27 16:00:19 +01:00
Georgy Komarov 3944e70e02
misra.py: Treat enum constants as constant known at compile time (#2823)
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
2020-09-25 21:02:34 +02:00
Daniel Marjamäki 6e4085f3d8 Misra: Write 12.3 warnings in structs/classes 2020-09-08 09:29:57 +02:00
Daniel Marjamäki f3fa7a6f5e misra: updated test addons/test/misra/misra-test.cpp 2020-09-06 13:25:37 +02:00
Georgy Komarov 4738da3d69
misra.py: Fix R12.3 FP on calling functions in function arguments (#2778) 2020-09-05 07:53:56 +02:00
Georgy Komarov 3bae716fd4
misra.py: Fix 20.7 false positive for multi-character arguments
See: https://trac.cppcheck.net/ticket/9633#comment:3
2020-08-08 13:03:19 +03:00
Georgy Komarov dc1faa71ed
misra.py: Fix false negatives in string concatenation for rule 20.7
This will fix Trac#9633
2020-07-24 07:15:40 +03:00
Georgy Komarov fc504ed6c3
misra.py: Fix false positives on macro expansion
This will fix Trac#9634
2020-07-21 20:03:04 +03:00
Georgy Komarov 90550d24c4
misra.py: Fix crash on volatile macro argument (#2654) 2020-05-21 08:34:28 +02:00
Georgy Komarov 61926ed7c3
misra.py: Fix false positive for rule 15.6 (#2631) 2020-05-07 16:54:27 +02:00
Georgy Komarov 20b02bff30
misra.py: Fix 20.7 FP for struct members (#2624)
This will close Trac#9673
2020-04-27 09:10:58 +02:00
Georgy Komarov 4e5a8fac4a
misra.py: Handle stdint.h essential types (#2555)
Add stdint.h essential types to misra.py checks. This will fix false
negatives for rules 10.6 and 10.8.
2020-02-27 11:28:48 +01:00
Georgy Komarov 9155f3a83a
misra.py: Check switch-clauses in R15.3 (#2538)
* misra.py: Check switch-clauses in R15.3

* break on violation
2020-02-16 00:03:18 +01:00
Georgy Komarov 2138091fa3
misra.py: Fix rule 20.2 false negative (#2534) 2020-02-12 17:11:56 +01:00
Georgy Komarov 403a61bc11
misra.py: Handle spaces in directive arguments (#2532) 2020-02-11 20:59:11 +01:00
Daniel Marjamäki 099dd57eb8 Fixed #9625 (false negative: misra-c2012-13.1) 2020-02-11 18:00:41 +01:00
Georgy Komarov 0ff23dbd0b misra.py: Handle more cases in Rule 20.3 check (#2529)
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.
2020-02-10 08:56:26 +01:00
Georgy Komarov f438cc6105
misra.py: Fix rule 21.1 false positives (#2526)
According MISRA standard, rule 21.1 should hanlde define/undef
directives only. There are no mentions of other C identifiers in the
standard document.
2020-02-09 16:22:26 +01:00
Georgy Komarov 6d4eff46be
misra.py: Fix false negative for rule 20.4 (#2528)
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.
2020-02-09 10:46:13 +01:00