misra 9.2: do not crash when checking. string literal is allowed to initialize array member. (#5232)
This commit is contained in:
parent
8d3fd88d3f
commit
a04990d4e3
|
@ -32,7 +32,7 @@ class ElementDef:
|
||||||
|
|
||||||
attrs = ["childIndex", "elementType", "valueType"]
|
attrs = ["childIndex", "elementType", "valueType"]
|
||||||
return "{}({}, {}, {})".format(
|
return "{}({}, {}, {})".format(
|
||||||
"ED",
|
"ElementDef",
|
||||||
self.getLongName(),
|
self.getLongName(),
|
||||||
inits,
|
inits,
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -255,6 +255,16 @@ class InitializerParser:
|
||||||
isFirstElement = False
|
isFirstElement = False
|
||||||
isDesignated = True
|
isDesignated = True
|
||||||
|
|
||||||
|
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 == '{':
|
elif self.token.str == '{':
|
||||||
nextChild = self.root.getNextChild() if self.root is not None else None
|
nextChild = self.root.getNextChild() if self.root is not None else None
|
||||||
|
|
||||||
|
@ -316,6 +326,7 @@ class InitializerParser:
|
||||||
else:
|
else:
|
||||||
self.ed.parent.setInitialized(isDesignated)
|
self.ed.parent.setInitialized(isDesignated)
|
||||||
self.ed.parent.initializeChildren()
|
self.ed.parent.initializeChildren()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if self.ed.parent != self.root:
|
if self.ed.parent != self.root:
|
||||||
# Check if token is correct value type for self.root.children[?]
|
# Check if token is correct value type for self.root.children[?]
|
||||||
|
@ -335,7 +346,15 @@ class InitializerParser:
|
||||||
parent = parent.parent
|
parent = parent.parent
|
||||||
isDesignated = False
|
isDesignated = False
|
||||||
|
|
||||||
self.unwindAndContinue()
|
if self.token.isString:
|
||||||
|
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()
|
||||||
|
else:
|
||||||
|
self.unwindAndContinue()
|
||||||
|
|
||||||
def pushToRootStackAndMarkAsDesignated(self):
|
def pushToRootStackAndMarkAsDesignated(self):
|
||||||
new = self.ed.parent
|
new = self.ed.parent
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _tGames
|
||||||
|
{
|
||||||
|
char magicdirname[10];
|
||||||
|
unsigned int expectedmask;
|
||||||
|
unsigned char pictureorder[3];
|
||||||
|
} tGames;
|
||||||
|
|
||||||
|
static const tGames games[1]={
|
||||||
|
{"Pawn", 1, {0,1,2}}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue