Skip to content

Commit 4a4b6fe

Browse files
committed
MISRA: Remove rule 5.3, Cppcheck core has these warnings
1 parent 55afaeb commit 4a4b6fe

2 files changed

Lines changed: 0 additions & 92 deletions

File tree

addons/misra.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -881,59 +881,6 @@ def misra_5_2(self, data):
881881
else:
882882
self.reportError(scopename2.bodyStart, 5, 2)
883883

884-
def misra_5_3(self, data):
885-
num_sign_chars = self.get_num_significant_naming_chars(data)
886-
enum = []
887-
scopeVars = {}
888-
for var in data.variables:
889-
if var.nameToken is not None:
890-
if var.nameToken.scope not in scopeVars:
891-
scopeVars[var.nameToken.scope] = []
892-
scopeVars[var.nameToken.scope].append(var)
893-
for innerScope in data.scopes:
894-
if innerScope.type == "Enum":
895-
enum_token = innerScope.bodyStart.next
896-
while enum_token != innerScope.bodyEnd:
897-
if enum_token.values and enum_token.isName:
898-
enum.append(enum_token.str)
899-
enum_token = enum_token.next
900-
continue
901-
if innerScope not in scopeVars:
902-
continue
903-
if innerScope.type == "Global":
904-
continue
905-
for innerVar in scopeVars[innerScope]:
906-
outerScope = innerScope.nestedIn
907-
while outerScope:
908-
if outerScope not in scopeVars:
909-
outerScope = outerScope.nestedIn
910-
continue
911-
for outerVar in scopeVars[outerScope]:
912-
if innerVar.nameToken.str[:num_sign_chars] == outerVar.nameToken.str[:num_sign_chars]:
913-
if outerVar.isArgument and outerScope.type == "Global" and not innerVar.isArgument:
914-
continue
915-
if int(innerVar.nameToken.linenr) > int(outerVar.nameToken.linenr):
916-
self.reportError(innerVar.nameToken, 5, 3)
917-
outerScope = outerScope.nestedIn
918-
for scope in data.scopes:
919-
if scope.className and innerVar.nameToken.str[:num_sign_chars] == scope.className[:num_sign_chars]:
920-
if int(innerVar.nameToken.linenr) > int(scope.bodyStart.linenr):
921-
self.reportError(innerVar.nameToken, 5, 3)
922-
else:
923-
self.reportError(scope.bodyStart, 5, 3)
924-
925-
for e in enum:
926-
for scope in data.scopes:
927-
if scope.className and innerVar.nameToken.str[:num_sign_chars] == e[:num_sign_chars]:
928-
if int(innerVar.nameToken.linenr) > int(innerScope.bodyStart.linenr):
929-
self.reportError(innerVar.nameToken, 5, 3)
930-
else:
931-
self.reportError(innerScope.bodyStart, 5, 3)
932-
for e in enum:
933-
for scope in data.scopes:
934-
if scope.className and scope.className[:num_sign_chars] == e[:num_sign_chars]:
935-
self.reportError(scope.bodyStart, 5, 3)
936-
937884
def misra_5_4(self, data):
938885
num_sign_chars = self.get_num_significant_naming_chars(data)
939886
macro = {}
@@ -2471,7 +2418,6 @@ def parseDump(self, dumpfile):
24712418
self.executeCheck(402, self.misra_4_2, data.rawTokens)
24722419
self.executeCheck(501, self.misra_5_1, cfg)
24732420
self.executeCheck(502, self.misra_5_2, cfg)
2474-
self.executeCheck(503, self.misra_5_3, cfg)
24752421
self.executeCheck(504, self.misra_5_4, cfg)
24762422
self.executeCheck(505, self.misra_5_5, cfg)
24772423
# 6.1 require updates in Cppcheck (type info for bitfields are lost)

addons/test/misra/misra-test.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -139,44 +139,6 @@ void misra_4_2()
139139
(void)printf("No?/Trigraph\n");
140140
}
141141

142-
extern int misra_5_3_var_hides_var______31x;
143-
void misra_5_3_var_hides_function_31x (void) {}
144-
enum misra_5_3_Enum {
145-
misra_5_3_var_hidesenumconst_31x = 2,misra_5_3_enum_hidesfunction_31x = 5
146-
};
147-
void misra_5_3_func1(void)
148-
{
149-
int misra_5_3_var_hides_var______31y; //5.3
150-
int misra_5_3_var_hides_function_31y; //5.3
151-
int misra_5_3_var_hidesenumconst_31y; //5.3
152-
switch(misra_5_3_func2()) //16.4 16.6
153-
{
154-
case 1:
155-
{
156-
do
157-
{
158-
int misra_5_3_var_hides_var_1____31x;
159-
if(misra_5_3_func3()) //14.4
160-
{
161-
int misra_5_3_var_hides_var_1____31y = 1; //5.3
162-
}
163-
} while(misra_5_3_func2()); //14.4
164-
}
165-
}
166-
}
167-
void misra_5_3_enum_hidesfunction_31y(void) {} //5.3
168-
extern bar_5_3(int i);
169-
void f_5_3( void )
170-
{
171-
{
172-
int i;
173-
i = 42;
174-
bar_5_3(i);
175-
}
176-
int i; // no warning
177-
}
178-
179-
180142
#define misra_5_4_macro_hides_macro__31x 1
181143
#define misra_5_4_param_hides_macro__31x 1
182144
#define misra_5_4_macro_hides_macro__31y 2 //5.4

0 commit comments

Comments
 (0)