From b35091b827cc338415a8fd300f18311d323e723d Mon Sep 17 00:00:00 2001 From: Georgy Komarov Date: Sat, 26 Oct 2019 18:29:38 +0300 Subject: [PATCH] misra.py: Fix 18.8 crash on checking undefined id (#2299) --- addons/misra.py | 3 +++ addons/test/misra/misra-test.c | 1 + 2 files changed, 4 insertions(+) diff --git a/addons/misra.py b/addons/misra.py index 3a137ad8d..564c6abc4 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1806,6 +1806,9 @@ class MisraChecker: typetok = var.nameToken.next if not typetok or typetok.str != '[': continue + # Unknown define or syntax error + if not typetok.astOperand2: + continue if not isConstantExpression(typetok.astOperand2): self.reportError(var.nameToken, 18, 8) diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index ed80f2ce3..eb1400e04 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -664,6 +664,7 @@ void misra_18_8(int x) { int buf1[10]; int buf2[sizeof(int)]; int vla[x]; // 18.8 + static const unsigned char arr18_8_1[] = UNDEFINED_ID; } union misra_19_2 { }; // 19.2