Bug hunting; avoid bughuntingUninitVar fp for template variable
This commit is contained in:
parent
0c6dc84cbb
commit
acfff072ae
|
@ -251,6 +251,10 @@ static void uninit(const Token *tok, const ExprEngine::Value &value, ExprEngine:
|
|||
if (tok->variable() && !tok->variable()->isPointer() && tok->variable()->isSmartPointer())
|
||||
return;
|
||||
|
||||
// template variable is not uninitialized
|
||||
if (tok->variable() && !tok->variable()->isPointer() && Token::findmatch(tok->variable()->typeStartToken(), "%name% <", tok->variable()->typeEndToken()))
|
||||
return;
|
||||
|
||||
// lhs in assignment
|
||||
if (tok->astParent()->str() == "=" && tok == tok->astParent()->astOperand1())
|
||||
return;
|
||||
|
|
|
@ -43,6 +43,7 @@ private:
|
|||
TEST_CASE(uninit_struct);
|
||||
TEST_CASE(uninit_bailout);
|
||||
TEST_CASE(uninit_fp_try_smartptr);
|
||||
TEST_CASE(uninit_fp_template_var);
|
||||
TEST_CASE(ctu);
|
||||
#endif
|
||||
}
|
||||
|
@ -185,6 +186,15 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninit_fp_template_var() {
|
||||
check("void foo() {\n"
|
||||
" X*x = DYNAMIC_CAST(X, p);\n"
|
||||
" C<int> c;\n"
|
||||
" f(c);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestBughuntingChecks)
|
||||
|
|
Loading…
Reference in New Issue