ValueFlow: fixed one more hang in valueFlowForward

This commit is contained in:
Daniel Marjamäki 2014-08-24 08:50:01 +02:00
parent 1060b30e52
commit 789b01aad2
2 changed files with 9 additions and 7 deletions

View File

@ -830,13 +830,9 @@ static bool valueFlowForward(Token * const startToken,
errorLogger, errorLogger,
tok2, tok2,
"no simplification of " + tok2->str() + " within " + (Token::Match(parent,"[?:]") ? "?:" : parent->str()) + " expression"); "no simplification of " + tok2->str() + " within " + (Token::Match(parent,"[?:]") ? "?:" : parent->str()) + " expression");
while (parent && parent->str() != "(") const Token *astTop = parent->astTop();
parent = parent->astParent(); if (Token::simpleMatch(astTop->astOperand1(), "for ("))
if (parent) { tok2 = const_cast<Token*>(astTop->link());
tok2 = const_cast<Token*>(parent->link());
if (Token::simpleMatch(tok2, ") ("))
tok2 = tok2->linkAt(1);
}
continue; continue;
} }

View File

@ -1002,6 +1002,12 @@ private:
"}"; "}";
testValueOfX(code, 0U, 0); testValueOfX(code, 0U, 0);
code = "void f() {\n" // don't hang in valueFlowForward analysis
" int x = 0;\n"
" f2((char*)a[b?c[x]:x]);\n"
"}";
testValueOfX(code, 0U, 0);
// TODO: float // TODO: float
code = "void f(float x) {\n" code = "void f(float x) {\n"
" if (x == 0.5) {}\n" " if (x == 0.5) {}\n"