misra.py: Fix 12.3 FP for variables defined in headers (#2773)
When we include the header file with variables definitions, Cppcheck will write `variables` entries with line numbers from the header to the dump file. If the line number in the header file and the source file are equal, misra.py performs an additional check what leads to false positives. Minimal example that demonstrates the problem: `misra_fp.c`: ```c void test_12_3_fp(void) { //Initialize the events queue QEQueue_init(&me->deferred_event_queue, me->deferred_events_queue_buf, Q_DIM(me->deferred_events_queue_buf)); } ``` `misra_fp.h`: ```c static const uint32_t timer_max_blocking_call_us; ``` This commit closes trac ticket 9874.
This commit is contained in:
parent
8027f40418
commit
e21bdb985c
|
@ -1690,8 +1690,9 @@ class MisraChecker:
|
|||
continue
|
||||
nt = v.nameToken
|
||||
if nt and nt.scope and nt.scope.type not in ('Enum', 'Class', 'Struct'):
|
||||
name_tokens_map.setdefault(nt.linenr, set())
|
||||
name_tokens_map[nt.linenr].add(nt.column)
|
||||
if nt.file == filename:
|
||||
name_tokens_map.setdefault(nt.linenr, set())
|
||||
name_tokens_map[nt.linenr].add(nt.column)
|
||||
if not name_tokens_map:
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue