diff --git a/addons/misra_9.py b/addons/misra_9.py index 4035cf0b2bf..806d27d225f 100644 --- a/addons/misra_9.py +++ b/addons/misra_9.py @@ -372,8 +372,11 @@ def unwindAndContinue(self): while self.token: if self.token.astParent.astOperand1 == self.token and self.token.astParent.astOperand2: if self.ed: - self.ed.markAsCurrent() - self.ed = self.ed.getNextValueElement(self.root) + if self.token.astParent.astOperand2.str == "{" and self.ed.isDesignated: + self.popFromStackIfExitElement() + else: + self.ed.markAsCurrent() + self.ed = self.ed.getNextValueElement(self.root) self.token = self.token.astParent.astOperand2 break diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index dfa6946cc72..7511e09f38d 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -501,6 +501,7 @@ static void misra_9_array_initializers_with_designators(void) { char c[2][2] = { [0] = {1, 2, 3} }; char d[1][2] = { [0] = 1 }; // 9.2 char e[2][2] = { { 1, 2 }, [1][0] = {3, 4} }; // 9.2 + int e1[2][2] = { [ 0 ][ 1 ] = 0, { 5, 6 } }; // no warning #12419 char f[2] = { [0] = 1, 2 }; char g[2] = { [1] = 2, [0] = 1 }; char h[2][2] = { { 1, 2 }, [1] = { 3 } }; // 9.3