diff --git a/addons/misra.py b/addons/misra.py index a93b9b518..680c8c199 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3358,9 +3358,9 @@ class MisraChecker: 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 diff --git a/addons/test/misra/crash10.c b/addons/test/misra/crash10.c new file mode 100644 index 000000000..455d86e57 --- /dev/null +++ b/addons/test/misra/crash10.c @@ -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; +}