ExprEngine: Improved handling of struct member assignments in loops
This commit is contained in:
parent
60de5e12dd
commit
d98ac017f7
|
@ -1258,10 +1258,6 @@ static void execute(const Token *start, const Token *end, Data &data)
|
||||||
if (!structScope)
|
if (!structScope)
|
||||||
throw VerifyException(tok2, "Unhandled assignment in loop");
|
throw VerifyException(tok2, "Unhandled assignment in loop");
|
||||||
const std::string &memberName = tok2->previous()->str();
|
const std::string &memberName = tok2->previous()->str();
|
||||||
ExprEngine::ValuePtr structVal1 = data.getValue(structToken->varId(), structToken->valueType(), structToken);
|
|
||||||
auto structVal = std::dynamic_pointer_cast<ExprEngine::StructValue>(structVal1);
|
|
||||||
if (!structVal)
|
|
||||||
throw VerifyException(tok2, "Unhandled assignment in loop");
|
|
||||||
ExprEngine::ValuePtr memberValue;
|
ExprEngine::ValuePtr memberValue;
|
||||||
for (const Variable &member : structScope->varlist) {
|
for (const Variable &member : structScope->varlist) {
|
||||||
if (memberName == member.name() && member.valueType()) {
|
if (memberName == member.name() && member.valueType()) {
|
||||||
|
@ -1272,6 +1268,13 @@ static void execute(const Token *start, const Token *end, Data &data)
|
||||||
if (!memberValue)
|
if (!memberValue)
|
||||||
throw VerifyException(tok2, "Unhandled assignment in loop");
|
throw VerifyException(tok2, "Unhandled assignment in loop");
|
||||||
|
|
||||||
|
ExprEngine::ValuePtr structVal1 = data.getValue(structToken->varId(), structToken->valueType(), structToken);
|
||||||
|
if (!structVal1)
|
||||||
|
structVal1 = createVariableValue(*structToken->variable(), data);
|
||||||
|
auto structVal = std::dynamic_pointer_cast<ExprEngine::StructValue>(structVal1);
|
||||||
|
if (!structVal)
|
||||||
|
throw VerifyException(tok2, "Unhandled assignment in loop");
|
||||||
|
|
||||||
data.assignStructMember(tok2, &*structVal, memberName, memberValue);
|
data.assignStructMember(tok2, &*structVal, memberName, memberValue);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue