Fixed #3707 (Uninitialized variable with operator >> and templates)

This commit is contained in:
Daniel Marjamäki 2012-04-24 19:50:54 +02:00
parent e0a3ca0845
commit fb6c7f33f0
2 changed files with 25 additions and 6 deletions

View File

@ -521,14 +521,26 @@ private:
}
} else {
const Token *tok2 = tok.next();
if (tok2->str() == "[" && Token::simpleMatch(tok2->link(), "] =")) {
if (use_dead_pointer(checks, &tok)) {
return &tok;
}
parserhs(tok2, checks);
tok2 = tok2->link()->next();
if (tok2->str() == "[") {
const Token *tok3 = tok2->link();
while (Token::simpleMatch(tok3, "] ["))
tok3 = tok3->next()->link();
// Possible initialization
if (Token::simpleMatch(tok3, "] >>"))
return &tok;
if (Token::simpleMatch(tok3, "] =")) {
if (use_dead_pointer(checks, &tok)) {
return &tok;
}
parserhs(tok2, checks);
tok2 = tok3->next();
}
}
parserhs(tok2, checks);
}

View File

@ -335,6 +335,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo() {\n" // #3707
" Node node;\n"
" int x;\n"
" node[\"abcd\"] >> x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int a(FArchive &arc) {\n" // #3060 (initialization through operator<<)
" int *p;\n"
" arc << p;\n"