diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b5229d3ce..8f929232e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1339,7 +1339,7 @@ private: const bool p(vartok->str() == "*"); if (p) 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)); return vartok->next(); } diff --git a/test/testother.cpp b/test/testother.cpp index e4444ddcf..cf9a1abc6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1006,6 +1006,13 @@ private: "}\n"); 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" "{\n" " A ret;\n"