misra.py: Fix crashes on obsolete GCC syntax for struct initialization (#3175)

* misra.py: Fix crashes on obsolete GCC syntax for struct initialization

* Added expected violations
This commit is contained in:
Georgiy Komarov 2021-03-20 15:59:39 +03:00 committed by GitHub
parent ad1f434c26
commit 390a5af064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -98,6 +98,8 @@ class ElementDef:
def getNextValueElement(self, root): def getNextValueElement(self, root):
current = self current = self
while current != root: while current != root:
if not current.parent:
return None
# Get next index of parent # Get next index of parent
i = current.parent.children.index(current) + 1 i = current.parent.children.index(current) + 1
# Next index of parent exists # Next index of parent exists

View File

@ -442,6 +442,9 @@ void misra_9_struct_initializers() {
dummy_struct dsd[2][2] = { 1, 2, 3, 4 }; // 9.2 dummy_struct dsd[2][2] = { 1, 2, 3, 4 }; // 9.2
dummy_struct dse[3] = { {1,2}, {3,4}, [1] = {5,6} }; // 9.3 9.4 dummy_struct dse[3] = { {1,2}, {3,4}, [1] = {5,6} }; // 9.3 9.4
dummy_struct dsd[] = { [0] = 1 }; // 9.5 dummy_struct dsd[] = { [0] = 1 }; // 9.5
// Obsolete initialization syntax for GCC
struct1 os1 = { i1: 1, i2: 2 }; // 10.4 13.4
} }
void misra_9_broken_initializers() { void misra_9_broken_initializers() {