This commit is contained in:
parent
fa7891e37b
commit
72a36172aa
|
@ -697,6 +697,11 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
|
|||
return true;
|
||||
}
|
||||
|
||||
// bailout if there is a pointer to member
|
||||
if (Token::Match(tok, "%varid% . *", var.declarationId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tok->str() == "?") {
|
||||
if (!tok->astOperand2())
|
||||
return true;
|
||||
|
|
|
@ -500,6 +500,8 @@ bool FwdAnalysis::possiblyAliased(const Token *expr, const Token *startToken) co
|
|||
{
|
||||
if (expr->isUnaryOp("*") && !expr->astOperand1()->isUnaryOp("&"))
|
||||
return true;
|
||||
if (Token::simpleMatch(expr, ". *"))
|
||||
return true;
|
||||
|
||||
const bool macro = false;
|
||||
const bool pure = false;
|
||||
|
|
|
@ -4875,6 +4875,15 @@ private:
|
|||
" return s;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("struct S { int i; };\n" // #12142
|
||||
"int f() {\n"
|
||||
" S s;\n"
|
||||
" int S::* p = &S::i;\n"
|
||||
" s.*p = 123;\n"
|
||||
" return s.i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar2_while() {
|
||||
|
|
|
@ -201,6 +201,7 @@ private:
|
|||
TEST_CASE(localvarStruct11); // 10095
|
||||
TEST_CASE(localvarStruct12); // #10495
|
||||
TEST_CASE(localvarStruct13); // #10398
|
||||
TEST_CASE(localvarStruct14);
|
||||
TEST_CASE(localvarStructArray);
|
||||
TEST_CASE(localvarUnion1);
|
||||
|
||||
|
@ -5330,6 +5331,17 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarStruct14() { // #12142
|
||||
functionVariableUsage("struct S { int i; };\n"
|
||||
"int f() {\n"
|
||||
" S s;\n"
|
||||
" int S::* p = &S::i;\n"
|
||||
" s.*p = 123;\n"
|
||||
" return s.i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarStructArray() {
|
||||
// extracttests.start: struct X {int a;};
|
||||
|
||||
|
|
Loading…
Reference in New Issue