Skip to content

Commit

Permalink
Fixed #12267 (Misra.py: crashes in 17.7 checker when there is macro i…
Browse files Browse the repository at this point in the history
…n variable declaration) (#5768)
  • Loading branch information
danmar committed Dec 15, 2023
1 parent c79ec60 commit 22613dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3358,9 +3358,9 @@ def misra_17_7(self, data):
continue
if token.str != '(' or token.astParent:
continue
if not token.astOperand1 or not token.astOperand1.isName:
if token.astOperand1 is None or not token.astOperand1.isName:
continue
if token.astOperand1.varId and get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None:
if token.astOperand1.varId and (token.astOperand1.variable is None or get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None):
continue
if token.valueType is None:
continue
Expand Down
12 changes: 12 additions & 0 deletions addons/test/misra/crash10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//#12267

extern uint32_t end;

//#define KEEP // if uncomment this then wont crash

KEEP static const int32_t ptr_to_end = &end;

void foo(void)
{
(void)ptr_to_end;
}

0 comments on commit 22613dc

Please sign in to comment.