misra.py: Fix 12.3 FP in initializer lists (#2489)

See: trac 9581
This commit is contained in:
Georgy Komarov 2020-01-15 11:55:59 +03:00 committed by orbitcowboy
parent 5ac0eb100c
commit 86d0f62d36
2 changed files with 17 additions and 3 deletions

View File

@ -1386,19 +1386,23 @@ class MisraChecker:
skip_to = None
for token in data.tokenlist:
# Skip tokens in function call body
if skip_to:
if token == skip_to:
skip_to = None
else:
continue
# Skip tokens in function call body
if token.function and token.next and token.next.str == "(":
skip_to = token.next.link
# Skip tokens in initializer lists
if simpleMatch(token, '= {'):
skip_to = token.next.link
if token.scope.type in ('Enum', 'Class', 'Struct', 'Global'):
continue
# Save end tokens from function calls in initialization
if simpleMatch(token, ') ;'):
# Save last tokens from function calls and initializer lists in
# initialization sequence
if simpleMatch(token, ') ;') or simpleMatch(token, '} ;'):
if (token.isExpandedMacro):
end_tokens_map[token.next.linenr].add(token.next.column)
else:

View File

@ -430,6 +430,16 @@ void misra_12_3(int a, int b, int c) { // no warning
misra_12_3_fn4(misra_12_3_fn7(&a1, 32), &a1);
misra_12_3_fn6(misra_12_3_fn5(&a1, 32), &a1);
misra_12_3_fn6(misra_12_3_fn7(&a1, 32), &a1);
const struct fun_t
{
int64_t x;
uint32_t y;
} moreFun[2U] =
{
{ 900000000000000LL, 0x20000UL },
{ 450000000000000LL, 0x10000UL }
};
}
#define MISRA12_4a 2000000000u