From dbe2a42e895515370987dc6089f5db020932d1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 22 May 2018 13:11:39 +0200 Subject: [PATCH] misra.py: Fixed 13.1 fp for struct initialization --- addons/misra.py | 6 +++--- addons/test/misra-test.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index 93f062155..a033e8e26 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -968,10 +968,10 @@ def misra_12_4(data): def misra_13_1(data): for token in data.tokenlist: - if token.str != '=': + if not simpleMatch(token, '] = {'): continue - init = token.next - if init and init.str == '{' and hasSideEffectsRecursive(init): + init = token.next.next + if hasSideEffectsRecursive(init): reportError(init, 13, 1) diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 72db1c314..9b4fd2d85 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -218,10 +218,12 @@ void misra_12_4() { x = 123456u * 123456u; // 12.4 } +struct misra_13_1_t { int a; int b; }; void misra_13_1(int *p) { volatile int v; int a[3] = {0, (*p)++, 2}; // 13.1 - int b[2] = {v,1}; // TODO + int b[2] = {v,1}; + struct misra_13_1_t c = { .a=4, .b=5 }; // no fp } void misra_13_3() {