misra.py: Fix 18.8 crash on checking undefined id (#2299)

This commit is contained in:
Georgy Komarov 2019-10-26 18:29:38 +03:00 committed by Daniel Marjamäki
parent 72f07c8a33
commit b35091b827
2 changed files with 4 additions and 0 deletions

View File

@ -1806,6 +1806,9 @@ class MisraChecker:
typetok = var.nameToken.next typetok = var.nameToken.next
if not typetok or typetok.str != '[': if not typetok or typetok.str != '[':
continue continue
# Unknown define or syntax error
if not typetok.astOperand2:
continue
if not isConstantExpression(typetok.astOperand2): if not isConstantExpression(typetok.astOperand2):
self.reportError(var.nameToken, 18, 8) self.reportError(var.nameToken, 18, 8)

View File

@ -664,6 +664,7 @@ void misra_18_8(int x) {
int buf1[10]; int buf1[10];
int buf2[sizeof(int)]; int buf2[sizeof(int)];
int vla[x]; // 18.8 int vla[x]; // 18.8
static const unsigned char arr18_8_1[] = UNDEFINED_ID;
} }
union misra_19_2 { }; // 19.2 union misra_19_2 { }; // 19.2