Fixed #2230 (segmentation fault of cppcheck)

This commit is contained in:
Robert Reif 2010-11-25 07:43:39 +01:00 committed by Daniel Marjamäki
parent 08b86e0b7e
commit 03b12c5494
2 changed files with 29 additions and 2 deletions

View File

@ -705,12 +705,21 @@ const Token *SymbolDatabase::initBaseInfo(SpaceInfo *info, const Token *tok)
} }
base.name += tok2->str(); base.name += tok2->str();
base.spaceInfo = 0; base.spaceInfo = 0;
// don't add unhandled templates
if (tok2->next()->str() == "<")
{
while (tok2->str() != ">")
tok2 = tok2->next();
}
// save pattern for base class name // save pattern for base class name
else
{
info->derivedFrom.push_back(base); info->derivedFrom.push_back(base);
} }
}
tok2 = tok2->next(); tok2 = tok2->next();
} }

View File

@ -171,6 +171,7 @@ private:
TEST_CASE(symboldatabase4); TEST_CASE(symboldatabase4);
TEST_CASE(symboldatabase5); // ticket #2178 TEST_CASE(symboldatabase5); // ticket #2178
TEST_CASE(symboldatabase6); // ticket #2221 TEST_CASE(symboldatabase6); // ticket #2221
TEST_CASE(symboldatabase7); // ticket #2230
} }
// Check the operator Equal // Check the operator Equal
@ -4860,6 +4861,23 @@ private:
"Y<X<(6>>1)>> x5;\n"); "Y<X<(6>>1)>> x5;\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void symboldatabase7()
{
// ticket #2230 - segmentation fault
checkConst("template<template<class> class E,class D> class C : E<D>\n"
"{\n"
"public:\n"
" int f();\n"
"};\n"
"class E : C<D,int>\n"
"{\n"
"public:\n"
" int f() { return C< ::D,int>::f(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
}; };
REGISTER_TEST(TestClass) REGISTER_TEST(TestClass)