misra: fix rule 5.4 false positive when macro is defined 'twice' inside #if/#else (#2125)
This commit is contained in:
parent
e8435b9ecb
commit
3740c57160
|
@ -880,7 +880,8 @@ class MisraChecker:
|
||||||
|
|
||||||
for x, m_var1 in enumerate(macro):
|
for x, m_var1 in enumerate(macro):
|
||||||
for y, m_var2 in enumerate(macro):
|
for y, m_var2 in enumerate(macro):
|
||||||
if x < y and macro[m_var1]["name"][:num_sign_chars] == macro[m_var2]["name"][:num_sign_chars]:
|
if x < y and macro[m_var1]["name"] != macro[m_var2]["name"] and \
|
||||||
|
macro[m_var1]["name"][:num_sign_chars] == macro[m_var2]["name"][:num_sign_chars]:
|
||||||
if m_var1.linenr > m_var2.linenr:
|
if m_var1.linenr > m_var2.linenr:
|
||||||
self.reportError(m_var1, 5, 4)
|
self.reportError(m_var1, 5, 4)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -104,6 +104,11 @@ void misra_5_3_enum_hidesfunction_31y(void) {} //5.3
|
||||||
#define misra_5_4_macro_hides_macro__31y 2 //5.4
|
#define misra_5_4_macro_hides_macro__31y 2 //5.4
|
||||||
#define m1(misra_5_4_param_hides_macro__31y) 1 //5.4
|
#define m1(misra_5_4_param_hides_macro__31y) 1 //5.4
|
||||||
#define m2(misra_5_4_param_hides_param__31x,misra_5_4_param_hides_param__31y) 1 //5.4
|
#define m2(misra_5_4_param_hides_param__31x,misra_5_4_param_hides_param__31y) 1 //5.4
|
||||||
|
#ifdef misra_5_4_macro_hides_macro__31x
|
||||||
|
#define misra_5_4_macro 1 // no warning
|
||||||
|
#else
|
||||||
|
#define misra_5_4_macro 2 // no warning
|
||||||
|
#endif
|
||||||
|
|
||||||
#define misra_5_5_var_hides_macro____31x 1
|
#define misra_5_5_var_hides_macro____31x 1
|
||||||
#define misra_5_5_functionhides_macro31x 1
|
#define misra_5_5_functionhides_macro31x 1
|
||||||
|
|
Loading…
Reference in New Issue