misra.py: Fix R7.2 crash on va_args (#2886)

This commit is contained in:
Georgy Komarov 2020-11-06 01:54:12 +03:00 committed by GitHub
parent 308b150351
commit 9cbb09076c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -1419,7 +1419,8 @@ class MisraChecker:
usedParameter = parametersUsed[i]
if usedParameter.isNumber:
parameterDefinition = functionDeclaration.argument.get(i+1)
reportErrorIfMissingSuffix(parameterDefinition.nameToken, usedParameter)
if parameterDefinition and parameterDefinition.nameToken:
reportErrorIfMissingSuffix(parameterDefinition.nameToken, usedParameter)
def misra_7_3(self, rawTokens):
compiled = re.compile(r'^[0-9.uU]+l')

View File

@ -227,6 +227,8 @@ void misra_7_1() {
void misra_7_2_call_test(int a, unsigned int b, unsigned int c) { } // 2.7
void misra_7_2_call_va_test(int a, ...) { } // 2.7
void misra_7_2() {
unsigned int a = 2147483647;
const unsigned int b = 2147483648U;
@ -247,6 +249,7 @@ void misra_7_2() {
misra_7_2_call_test(1, 2, 2147483648U);
misra_7_2_call_test(1, 2, 2147483648); // 7.2
misra_7_2_call_test(1, 0x80000000, 3); // 7.2
misra_7_2_call_va_test(1, 2, 3);
}
void misra_7_3() {