Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jul 10, 2023
1 parent 652648b commit da3ba53
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions addons/misra_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __repr__(self):

attrs = ["childIndex", "elementType", "valueType"]
return "{}({}, {}, {})".format(
"ED",
"ElementDef",
self.getLongName(),
inits,
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
Expand Down Expand Up @@ -255,21 +255,21 @@ def parseInitializer(self, root, token):
isFirstElement = False
isDesignated = True

elif self.token.str == '{' or self.token.isString:
elif self.token.isString and self.ed.isArray:
self.ed.setInitialized(isDesignated)
if self.token == self.token.astParent.astOperand1 and self.token.astParent.astOperand2:
self.token = self.token.astParent.astOperand2
self.ed.markAsCurrent()
self.ed = self.root.getNextChild()
else:
self.unwindAndContinue()
continue

elif self.token.str == '{':
nextChild = self.root.getNextChild() if self.root is not None else None

if nextChild:
if nextChild.isArray and self.token.isString:
# Zero initializer causes recursive initialization
nextChild.setInitialized(isDesignated)
if self.token == self.token.astParent.astOperand1 and self.token.astParent.astOperand2:
self.token = self.token.astParent.astOperand2
self.ed.markAsCurrent()
self.ed = self.root.getNextChild()
else:
self.unwindAndContinue()
continue
elif nextChild.isArray or nextChild.isRecord:
if nextChild.isArray or nextChild.isRecord:
nextChild.unset()
nextChild.setInitialized(isDesignated)
self.ed = nextChild.getFirstValueElement()
Expand Down

0 comments on commit da3ba53

Please sign in to comment.