Merge branch 'master' of https://github.com/danmar/cppcheck
This commit is contained in:
commit
a7ded1e19f
|
@ -1495,9 +1495,12 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
|
|||
*alloc = true;
|
||||
continue;
|
||||
}
|
||||
if (var.isPointer() && (_tokenizer->isC() || var.typeStartToken()->isStandardType() || (var.type() && var.type()->needInitialization == Type::True)) && Token::Match(tok->next(), "= new")) {
|
||||
if (alloc)
|
||||
if (var.isPointer() && (var.typeStartToken()->isStandardType() || (var.type() && var.type()->needInitialization == Type::True)) && Token::Match(tok->next(), "= new")) {
|
||||
if (alloc) {
|
||||
*alloc = true;
|
||||
if (var.typeScope()->numConstructors > 0)
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1455,21 +1455,28 @@ private:
|
|||
"{\n"
|
||||
" Fred *fred = new Fred;\n"
|
||||
" fred->foo();\n"
|
||||
"};");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVarB("struct Fred { int i; Fred(int, float); };\n"
|
||||
"void f() {\n"
|
||||
" Fred *fred = new Fred(1, 2);\n"
|
||||
" fred->foo();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVarB("void f()\n"
|
||||
"{\n"
|
||||
" Fred *fred = malloc(sizeof(Fred));\n"
|
||||
" x(&fred->f);\n"
|
||||
"};");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVarB("void f()\n"
|
||||
"{\n"
|
||||
" Fred *fred = malloc(sizeof(Fred));\n"
|
||||
" x(fred->f);\n"
|
||||
"};");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVarB("void foo(char *s)\n"
|
||||
|
|
Loading…
Reference in New Issue