Skip to content

Commit 22613dc

Browse files
authored
Fixed #12267 (Misra.py: crashes in 17.7 checker when there is macro in variable declaration) (#5768)
1 parent c79ec60 commit 22613dc

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

addons/misra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,9 +3358,9 @@ def misra_17_7(self, data):
33583358
continue
33593359
if token.str != '(' or token.astParent:
33603360
continue
3361-
if not token.astOperand1 or not token.astOperand1.isName:
3361+
if token.astOperand1 is None or not token.astOperand1.isName:
33623362
continue
3363-
if token.astOperand1.varId and get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None:
3363+
if token.astOperand1.varId and (token.astOperand1.variable is None or get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None):
33643364
continue
33653365
if token.valueType is None:
33663366
continue

addons/test/misra/crash10.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//#12267
2+
3+
extern uint32_t end;
4+
5+
//#define KEEP // if uncomment this then wont crash
6+
7+
KEEP static const int32_t ptr_to_end = &end;
8+
9+
void foo(void)
10+
{
11+
(void)ptr_to_end;
12+
}

0 commit comments

Comments
 (0)