Skip to content

Commit 272028c

Browse files
authored
Fix #12419: false positive: misra-c2012-9.2 (#5964)
1 parent e98b98d commit 272028c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

addons/misra_9.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,11 @@ def unwindAndContinue(self):
372372
while self.token:
373373
if self.token.astParent.astOperand1 == self.token and self.token.astParent.astOperand2:
374374
if self.ed:
375-
self.ed.markAsCurrent()
376-
self.ed = self.ed.getNextValueElement(self.root)
375+
if self.token.astParent.astOperand2.str == "{" and self.ed.isDesignated:
376+
self.popFromStackIfExitElement()
377+
else:
378+
self.ed.markAsCurrent()
379+
self.ed = self.ed.getNextValueElement(self.root)
377380

378381
self.token = self.token.astParent.astOperand2
379382
break

addons/test/misra/misra-test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ static void misra_9_array_initializers_with_designators(void) {
501501
char c[2][2] = { [0] = {1, 2, 3} };
502502
char d[1][2] = { [0] = 1 }; // 9.2
503503
char e[2][2] = { { 1, 2 }, [1][0] = {3, 4} }; // 9.2
504+
int e1[2][2] = { [ 0 ][ 1 ] = 0, { 5, 6 } }; // no warning #12419
504505
char f[2] = { [0] = 1, 2 };
505506
char g[2] = { [1] = 2, [0] = 1 };
506507
char h[2][2] = { { 1, 2 }, [1] = { 3 } }; // 9.3

0 commit comments

Comments
 (0)