Fixed #6432 (cppcheck fails to detect ctor - partial template specialization)

This commit is contained in:
Robert Reif 2015-01-19 16:15:11 +01:00 committed by Daniel Marjamäki
parent 81aaa02c76
commit 56dc0b02ef
2 changed files with 29 additions and 1 deletions

View File

@ -52,7 +52,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
"SymbolDatabase",
tok->progressValue());
// Locate next class
if (Token::Match(tok, "class|struct|union|namespace ::| %var% {|:|::") &&
if (Token::Match(tok, "class|struct|union|namespace ::| %var% {|:|::|<") &&
tok->strAt(-1) != "friend") {
const Token *tok2 = tok->tokAt(2);
@ -62,6 +62,10 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
while (tok2 && tok2->str() == "::")
tok2 = tok2->tokAt(2);
// skip over template args
if (tok2 && tok2->str() == "<" && tok2->link())
tok2 = tok2->link()->next();
// make sure we have valid code
if (!tok2 || !Token::Match(tok2, "{|:")) {
// check for qualified variable

View File

@ -225,6 +225,7 @@ private:
TEST_CASE(symboldatabase47); // #6308
TEST_CASE(symboldatabase48); // #6417
TEST_CASE(symboldatabase49); // #6424
TEST_CASE(symboldatabase50); // #6432
TEST_CASE(isImplicitlyVirtual);
@ -2091,6 +2092,29 @@ private:
ASSERT_EQUALS(true, db && f && f->function());
}
void symboldatabase50() { // #6432
GET_SYMBOL_DB("template <bool del, class T>\n"
"class _ConstTessMemberResultCallback_0_0<del, void, T>\n"
" {\n"
" public:\n"
" typedef void (T::*MemberSignature)() const;\n"
"\n"
" private:\n"
" const T* object_;\n"
" MemberSignature member_;\n"
"\n"
" public:\n"
" inline _ConstTessMemberResultCallback_0_0(\n"
" const T* object, MemberSignature member)\n"
" : object_(object),\n"
" member_(member) {\n"
" }\n"
"};");
ASSERT(db != nullptr);
const Token *f = Token::findsimplematch(tokenizer.tokens(), "_ConstTessMemberResultCallback_0_0 (");
ASSERT_EQUALS(true, db && f && f->function() && f->function()->isConstructor());
}
void isImplicitlyVirtual() {
{
GET_SYMBOL_DB("class Base {\n"