Fixed #3707 (Uninitialized variable with operator >> and templates)
This commit is contained in:
parent
e0a3ca0845
commit
fb6c7f33f0
|
@ -521,14 +521,26 @@ private:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Token *tok2 = tok.next();
|
const Token *tok2 = tok.next();
|
||||||
if (tok2->str() == "[" && Token::simpleMatch(tok2->link(), "] =")) {
|
|
||||||
if (use_dead_pointer(checks, &tok)) {
|
|
||||||
return &tok;
|
|
||||||
}
|
|
||||||
|
|
||||||
parserhs(tok2, checks);
|
if (tok2->str() == "[") {
|
||||||
tok2 = tok2->link()->next();
|
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);
|
parserhs(tok2, checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,6 +335,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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<<)
|
checkUninitVar("int a(FArchive &arc) {\n" // #3060 (initialization through operator<<)
|
||||||
" int *p;\n"
|
" int *p;\n"
|
||||||
" arc << p;\n"
|
" arc << p;\n"
|
||||||
|
|
Loading…
Reference in New Issue