From 9cbb09076cb1224c3a4dc651b1c53c9c20dcba70 Mon Sep 17 00:00:00 2001 From: Georgy Komarov Date: Fri, 6 Nov 2020 01:54:12 +0300 Subject: [PATCH] misra.py: Fix R7.2 crash on va_args (#2886) --- addons/misra.py | 3 ++- addons/test/misra/misra-test.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index bebe6e714..db467588a 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -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') diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index a1ac5eea5..80f4ba297 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -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() {