Fixed #3195 (operator() from a functor-struct is never used)

This commit is contained in:
Daniel Marjamäki 2011-10-29 20:04:43 +02:00
parent 09bdacf31f
commit 24a2b6e6ba
2 changed files with 11 additions and 1 deletions

View File

@ -147,7 +147,11 @@ void CheckUnusedFunctions::check(ErrorLogger * const errorLogger)
const FunctionUsage &func = it->second;
if (func.usedOtherFile || func.filename.empty())
continue;
if (it->first == "main" || it->first == "WinMain" || it->first == "_tmain" || it->first == "if")
if (it->first == "main" ||
it->first == "WinMain" ||
it->first == "_tmain" ||
it->first == "if" ||
(it->first.compare(0, 8, "operator") == 0 && it->first.size() > 8 && !std::isalnum(it->first[8])))
continue;
if (! func.usedSameFile) {
std::string filename;

View File

@ -44,6 +44,7 @@ private:
TEST_CASE(unusedError);
TEST_CASE(unusedMain);
TEST_CASE(initializationIsNotAFunction);
TEST_CASE(operator1); // #3195
TEST_CASE(multipleFiles); // same function name in multiple files
@ -186,6 +187,11 @@ private:
ASSERT_EQUALS("", errout.str());
}
void operator1() {
check("struct Foo { void operator()(int a) {} };");
ASSERT_EQUALS("", errout.str());
}
void multipleFiles() {
CheckUnusedFunctions c;