misra: Fix crash on rule 9.x (#3024)

Closes ticket #10084
This commit is contained in:
Georgiy Komarov 2021-01-07 17:04:12 +03:00 committed by GitHub
parent 2b22120d22
commit 82f51bd523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -430,7 +430,7 @@ def createArrayChildrenDefs(ed, token, rawTokens = None):
if foundToken and foundToken.next and foundToken.next.str == ']':
ed.markAsFlexibleArray(token)
if token.astOperand2 is not None:
if (token.astOperand2 is not None) and (token.astOperand2.getKnownIntValue() is not None):
for i in range(token.astOperand2.getKnownIntValue()):
createChild(ed, token, i)
else:

View File

@ -444,6 +444,10 @@ void misra_9_struct_initializers() {
dummy_struct dsd[] = { [0] = 1 }; // 9.5
}
void misra_9_broken_initializers() {
char a[UNKNOWN_MACRO] = { 19, 23, 0 }; // 18.8
}
void misra_9_2() {
union misra_9_2_union { // 19.2
char c;