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
This commit is contained in:
Georgiy Komarov 2021-07-01 22:08:40 +03:00 committed by GitHub
parent 9be88a06fe
commit 426117a30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -1500,7 +1500,10 @@ class MisraChecker:
break
voidArg = voidArg.next
if not voidArg.str == 'void':
self.reportError(func.tokenDef, 8, 2)
if func.tokenDef.next:
self.reportError(func.tokenDef.next, 8, 2)
else:
self.reportError(func.tokenDef, 8, 2)
def checkDeclarationArgumentsViolations(func, startCall, endCall):
# Collect the tokens for the arguments in function definition
@ -1528,7 +1531,10 @@ class MisraChecker:
startCall = startCall.next
if len(argNameTokens) != foundVariables:
self.reportError(func.tokenDef, 8, 2)
if func.tokenDef.next:
self.reportError(func.tokenDef.next, 8, 2)
else:
self.reportError(func.tokenDef, 8, 2)
def checkDefinitionArgumentsViolations(func, startCall, endCall):
for arg in func.argument:

View File

@ -354,6 +354,8 @@ int misra_8_2_p(
const uint32_t a1,
const uint8_t *const a2
);
int misra_8_2_q
(); // 8.2
extern int a811[]; // 8.11