From 62dbe2eb2fc76c9c67c148e0d5f0a8ea89781f67 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Sun, 27 Jun 2021 23:57:50 +0300 Subject: [PATCH] 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 --- addons/misra.py | 3 +-- addons/test/misra/misra-test.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index e6c62c2b5..2d7572419 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1530,8 +1530,7 @@ class MisraChecker: self.reportError(typeStartToken, 8, 2) # Type declaration on next line (old style declaration list) is not allowed - if ((typeStartToken.linenr > endCall.linenr) or - (typeStartToken.column > endCall.column)): + if typeStartToken.linenr > endCall.linenr: self.reportError(typeStartToken, 8, 2) # Check arguments in function declaration diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index c27ed23b3..ba64968d4 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -327,10 +327,17 @@ void misra_8_2_m(uint8_t * const x) int16_t ( *misra_8_2_p_a ) (); // 8.2 int16_t ( *misra_8_2_p_b ) (void); int16_t ( *misra_8_2_p_c ) (int); -int misra_8_2_no_fp (int a) -{ - return a + 42; -} +int misra_8_2_n(int a) +{ return a + 42; } +int misra_8_2_o( + const uint32_t a1, + const uint8_t *const a2 +) +{ return *a2 + a1; } +int misra_8_2_p( + const uint32_t a1, + const uint8_t *const a2 +); extern int a811[]; // 8.11