fix #2807 (Wrong handling of function references when prefixed with &)

This commit is contained in:
Robert Reif 2011-06-29 07:19:34 -04:00
parent 1286898fa0
commit 6eecab5d73
2 changed files with 17 additions and 1 deletions

View File

@ -662,7 +662,7 @@ void CheckClass::privateFunctions()
while (!FuncList.empty()) while (!FuncList.empty())
{ {
// Final check; check if the function pointer is used somewhere.. // Final check; check if the function pointer is used somewhere..
const std::string _pattern("return|(|)|,|= " + FuncList.front()->str()); const std::string _pattern("return|(|)|,|= &|" + FuncList.front()->str());
// or if the function address is used somewhere... // or if the function address is used somewhere...
// eg. sigc::mem_fun(this, &className::classFunction) // eg. sigc::mem_fun(this, &className::classFunction)

View File

@ -45,6 +45,7 @@ private:
TEST_CASE(func_pointer1); TEST_CASE(func_pointer1);
TEST_CASE(func_pointer2); TEST_CASE(func_pointer2);
TEST_CASE(func_pointer3); TEST_CASE(func_pointer3);
TEST_CASE(func_pointer4); // ticket #2807
TEST_CASE(ctor); TEST_CASE(ctor);
@ -298,6 +299,21 @@ private:
} }
void func_pointer4() // ticket #2807
{
check("class myclass {\n"
"public:\n"
" myclass();\n"
"private:\n"
" static void f();\n"
" void (*fptr)();\n"
"};\n"
"myclass::myclass() { fptr = &f; }\n"
"void myclass::f() {}\n");
ASSERT_EQUALS("", errout.str());
}
void ctor() void ctor()
{ {
check("class PrivateCtor\n" check("class PrivateCtor\n"