Skip to content

Commit

Permalink
Fix #12419: false positive: misra-c2012-9.2 (#5964)
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 authored Feb 9, 2024
1 parent e98b98d commit 272028c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions addons/misra_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 272028c

Please sign in to comment.