Fixed #3195 (operator() from a functor-struct is never used)
This commit is contained in:
parent
09bdacf31f
commit
24a2b6e6ba
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue