From c2b514dc45d2f885e89077c846bc1f566c08d974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 10 Oct 2019 11:12:36 +0200 Subject: [PATCH] ExprEngine: Throw exception if assignment in loop is not handled --- lib/exprengine.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 107b9599d..900354066 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1247,13 +1247,15 @@ static void execute(const Token *start, const Token *end, Data &data) // TODO this is very rough code std::set changedVariables; for (const Token *tok2 = tok; tok2 != bodyEnd; tok2 = tok2->next()) { - if (Token::Match(tok2, "%var% %assign%")) { + if (Token::Match(tok2, "%assign%")) { + if (!Token::Match(tok2->astOperand1(), "%var%")) + throw VerifyException(tok2, "Unhandled assignment in loop"); // give variable "any" value - int varid = tok2->varId(); + int varid = tok2->astOperand1()->varId(); if (changedVariables.find(varid) != changedVariables.end()) continue; changedVariables.insert(varid); - data.assignValue(tok2->next(), varid, createVariableValue(*tok2->variable(), data)); + data.assignValue(tok2, varid, createVariableValue(*tok2->astOperand1()->variable(), data)); } else if (Token::Match(tok2, "++|--") && tok2->astOperand1() && tok2->astOperand1()->variable()) { // give variable "any" value const Token *vartok = tok2->astOperand1();