This commit is contained in:
parent
d75331d00d
commit
f934d6e5d0
|
@ -2432,7 +2432,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
|
|||
int derefs = 0;
|
||||
while (Token::simpleMatch(tok2->astParent(), "*") ||
|
||||
(Token::simpleMatch(tok2->astParent(), ".") && !Token::simpleMatch(tok2->astParent()->astParent(), "(")) ||
|
||||
(tok2->astParent() && tok2->astParent()->isUnaryOp("&") && !tok2->astParent()->astOperand2() && Token::simpleMatch(tok2->astParent()->astParent(), ".") && tok2->astParent()->astParent()->originalName()=="->") ||
|
||||
(tok2->astParent() && tok2->astParent()->isUnaryOp("&") && Token::simpleMatch(tok2->astParent()->astParent(), ".") && tok2->astParent()->astParent()->originalName()=="->") ||
|
||||
(Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1())) {
|
||||
if (tok2->astParent() && (tok2->astParent()->isUnaryOp("*") || (astIsLHS(tok2) && tok2->astParent()->originalName() == "->")))
|
||||
derefs++;
|
||||
|
@ -2443,6 +2443,14 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
|
|||
tok2 = tok2->astParent();
|
||||
}
|
||||
|
||||
if (tok2->astParent() && tok2->astParent()->isUnaryOp("&")) {
|
||||
const Token* parent = tok2->astParent();
|
||||
while (parent->astParent() && parent->astParent()->isCast())
|
||||
parent = parent->astParent();
|
||||
if (parent->astParent() && parent->astParent()->isUnaryOp("*"))
|
||||
tok2 = parent->astParent();
|
||||
}
|
||||
|
||||
while ((Token::simpleMatch(tok2, ":") && Token::simpleMatch(tok2->astParent(), "?")) ||
|
||||
(Token::simpleMatch(tok2->astParent(), ":") && Token::simpleMatch(tok2->astParent()->astParent(), "?")))
|
||||
tok2 = tok2->astParent();
|
||||
|
|
|
@ -5295,7 +5295,7 @@ private:
|
|||
// initialization
|
||||
code = "int foo() {\n"
|
||||
" int x;\n"
|
||||
" *((int *)(&x)) = 12;"
|
||||
" *((int *)(&x)) = 12;\n"
|
||||
" a = x + 1;\n"
|
||||
"}";
|
||||
values = tokenValues(code, "x +");
|
||||
|
@ -5304,6 +5304,18 @@ private:
|
|||
// ASSERT(values.front().isIntValue());
|
||||
// ASSERT_EQUALS(12, values.front().intvalue);
|
||||
|
||||
code = "struct AB { int a; };\n" // 11767
|
||||
"void fp(void) {\n"
|
||||
" struct AB ab;\n"
|
||||
" *((int*)(&(ab.a))) = 1;\n"
|
||||
" x = ab.a + 1;\n" // <- not uninitialized
|
||||
"}\n";
|
||||
values = tokenValues(code, "ab . a +");
|
||||
ASSERT_EQUALS(0, values.size());
|
||||
// ASSERT_EQUALS(1U, values.size());
|
||||
// ASSERT(values.front().isIntValue());
|
||||
// ASSERT_EQUALS(1, values.front().intvalue);
|
||||
|
||||
// #8036
|
||||
code = "void foo() {\n"
|
||||
" int x;\n"
|
||||
|
|
Loading…
Reference in New Issue