diff --git a/addons/misra_9.py b/addons/misra_9.py index ae46e1f17aa..4035cf0b2bf 100644 --- a/addons/misra_9.py +++ b/addons/misra_9.py @@ -311,7 +311,7 @@ def parseInitializer(self, root, token): if self.ed and self.ed.isValue: if not isDesignated and len(self.rootStack) > 0 and self.rootStack[-1][1] == self.root: self.rootStack[-1][0].markStuctureViolation(self.token) - if isFirstElement and self.token.isInt and self.token.getKnownIntValue() == 0 and self.token.next.str == '}': + if isFirstElement and self.token.str == '0' and self.token.next.str == '}': # Zero initializer causes recursive initialization self.root.initializeChildren() elif self.token.isString and self.ed.valueType and self.ed.valueType.pointer > 0: diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 0bb90de37c4..dfa6946cc72 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -441,7 +441,10 @@ static void misra_9_empty_or_zero_initializers(void) { int e[2][2] = { { 1 , 2 }, {} }; // 9.2 int f[5] = { 0 }; - int f1[5] = { 0u }; // no-warning #11298 + int f1[5] = { 0u }; // 9.3 + unsigned int f1[ 3 ][ 2 ] = { 0U }; // 9.3 9.2 + unsigned int f2[ 3 ] = { 0U }; // 9.3 + float f3[ 3 ][ 2 ] = { 0.0F }; // 9.3 9.2 int g[5][2] = { 0 }; int h[2][2] = { { 0 } }; // 9.3 int i[2][2] = { { 0 }, { 0 } };