Fixed #8800 (Possible variable assignment ignored in boolean expression)
This commit is contained in:
parent
e18c846ed9
commit
2887ee10c0
|
@ -2363,6 +2363,14 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
const Token *astTop = parent->astTop();
|
const Token *astTop = parent->astTop();
|
||||||
if (Token::simpleMatch(astTop->astOperand1(), "for ("))
|
if (Token::simpleMatch(astTop->astOperand1(), "for ("))
|
||||||
tok2 = const_cast<Token*>(astTop->link());
|
tok2 = const_cast<Token*>(astTop->link());
|
||||||
|
|
||||||
|
// bailout if address of var is taken..
|
||||||
|
if (tok2->astParent() && tok2->astParent()->isUnaryOp("&")) {
|
||||||
|
if (settings->debugwarnings)
|
||||||
|
bailout(tokenlist, errorLogger, tok2, "Taking address of " + tok2->str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2239,6 +2239,15 @@ private:
|
||||||
" return x;\n"
|
" return x;\n"
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(true, testValueOfX(code, 8U, 1));
|
ASSERT_EQUALS(true, testValueOfX(code, 8U, 1));
|
||||||
|
|
||||||
|
code = "int f(int *);\n"
|
||||||
|
"int g() {\n"
|
||||||
|
" const int a = 1;\n"
|
||||||
|
" int x = 11;\n"
|
||||||
|
" c = (a && f(&x));\n"
|
||||||
|
" if (x == 42) {}\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 6U, 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowForwardTernary() {
|
void valueFlowForwardTernary() {
|
||||||
|
|
Loading…
Reference in New Issue