Fixed #4449 (segfault in CheckClass::initializeVarList())

This commit is contained in:
Robert Reif 2012-12-29 08:30:14 +01:00 committed by Daniel Marjamäki
parent 1f87c6d669
commit 07d118dee5
2 changed files with 10 additions and 1 deletions

View File

@ -356,7 +356,7 @@ bool CheckClass::isBaseClassFunc(const Token *tok, const Scope *scope)
void CheckClass::initializeVarList(const Function &func, std::list<std::string> &callstack, const Scope *scope, std::vector<Usage> &usage) void CheckClass::initializeVarList(const Function &func, std::list<std::string> &callstack, const Scope *scope, std::vector<Usage> &usage)
{ {
bool initList = true; bool initList = func.type == Function::eConstructor || func.type == Function::eCopyConstructor;
const Token *ftok = func.arg->link()->next(); const Token *ftok = func.arg->link()->next();
int level = 0; int level = 0;
for (; ftok != func.functionScope->classEnd; ftok = ftok->next()) { for (; ftok != func.functionScope->classEnd; ftok = ftok->next()) {

View File

@ -82,6 +82,7 @@ private:
TEST_CASE(initvar_nocopy3); // ticket #3611 TEST_CASE(initvar_nocopy3); // ticket #3611
TEST_CASE(initvar_destructor); // No variables need to be initialized in a destructor TEST_CASE(initvar_destructor); // No variables need to be initialized in a destructor
TEST_CASE(initvar_func_ret_func_ptr); // ticket #4449
TEST_CASE(operatorEqSTL); TEST_CASE(operatorEqSTL);
@ -944,6 +945,14 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void initvar_func_ret_func_ptr() { // ticket #4449 (segmentation fault)
check("class something {\n"
" int * ( something :: * process()) () { return 0; }\n"
" something() { process(); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void operatorEqSTL() { void operatorEqSTL() {
check("class Fred\n" check("class Fred\n"
"{\n" "{\n"