misra.py: Fixed 13.1 fp for struct initialization

This commit is contained in:
Daniel Marjamäki 2018-05-22 13:11:39 +02:00
parent a3b02d6ece
commit dbe2a42e89
2 changed files with 6 additions and 4 deletions

View File

@ -968,10 +968,10 @@ def misra_12_4(data):
def misra_13_1(data): def misra_13_1(data):
for token in data.tokenlist: for token in data.tokenlist:
if token.str != '=': if not simpleMatch(token, '] = {'):
continue continue
init = token.next init = token.next.next
if init and init.str == '{' and hasSideEffectsRecursive(init): if hasSideEffectsRecursive(init):
reportError(init, 13, 1) reportError(init, 13, 1)

View File

@ -218,10 +218,12 @@ void misra_12_4() {
x = 123456u * 123456u; // 12.4 x = 123456u * 123456u; // 12.4
} }
struct misra_13_1_t { int a; int b; };
void misra_13_1(int *p) { void misra_13_1(int *p) {
volatile int v; volatile int v;
int a[3] = {0, (*p)++, 2}; // 13.1 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() { void misra_13_3() {