From d9e1cc957b64c69a8c39053b295caaa9c7c08804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 7 Oct 2018 17:19:40 +0200 Subject: [PATCH] Fixed #8704 (false postive: MISRA rule 5.2) --- addons/misra.py | 2 +- addons/test/misra-test.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index 1951d80a0..0ff8ea038 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -635,7 +635,7 @@ class MisraChecker: for variable2 in scopeVars[scope]["varlist"][i + 1:]: if variable1.isArgument and variable2.isArgument: continue - if variable1.isExtern and variable2.isExtern: + if variable1.isExtern or variable2.isExtern: continue if (variable1.nameToken.str[:31] == variable2.nameToken.str[:31] and variable1.Id != variable2.Id): diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index e80ac1caf..e52da1a2a 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -25,7 +25,9 @@ typedef unsigned long long u64; extern int misra_5_1_extern_var_hides_var_x; extern int misra_5_1_extern_var_hides_var_y; //5.1 -extern int misra_5_2_var_hides_var______31x; +extern const uint8_t misra_5_2_var1; +const uint8_t misra_5_2_var1 = 3; // no warning +static int misra_5_2_var_hides_var______31x; static int misra_5_2_var_hides_var______31y;//5.2 static int misra_5_2_function_hides_var_31x; void misra_5_2_function_hides_var_31y(void) {}//5.2