Fixed #1137 (false positive: uninitialized variable when using a class object)

This commit is contained in:
Daniel Marjamäki 2009-12-23 13:57:01 +01:00
parent 5a89cc3259
commit ef21ba7425
2 changed files with 8 additions and 1 deletions

View File

@ -1339,7 +1339,7 @@ private:
const bool p(vartok->str() == "*"); const bool p(vartok->str() == "*");
if (p) if (p)
vartok = vartok->next(); vartok = vartok->next();
if (vartok->varId() != 0) if ((p || tok.isStandardType()) && vartok->varId() != 0)
checks.push_back(new CheckUninitVar(owner, vartok->varId(), vartok->str(), p, false)); checks.push_back(new CheckUninitVar(owner, vartok->varId(), vartok->str(), p, false));
return vartok->next(); return vartok->next();
} }

View File

@ -1006,6 +1006,13 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("static void foo()\n"
"{\n"
" Foo p;\n"
" int x = p.abcd();\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("A a()\n" checkUninitVar("A a()\n"
"{\n" "{\n"
" A ret;\n" " A ret;\n"