fix #3127 ([False positive] _tmain function i VS 2010 project)

This commit is contained in:
Robert Reif 2011-09-21 20:16:20 -04:00
parent 5e329d7280
commit 1dc7c0edf9
2 changed files with 14 additions and 1 deletions

View File

@ -161,7 +161,7 @@ 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 == "if")
if (it->first == "main" || it->first == "WinMain" || it->first == "_tmain" || it->first == "if")
continue;
if (! func.usedSameFile)
{

View File

@ -44,6 +44,7 @@ private:
TEST_CASE(template1);
TEST_CASE(throwIsNotAFunction);
TEST_CASE(unusedError);
TEST_CASE(unusedMain);
TEST_CASE(initializationIsNotAFunction);
TEST_CASE(multipleFiles); // same function name in multiple files
@ -179,6 +180,18 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (style) The function 'foo' is never used\n", errout.str());
}
void unusedMain()
{
check("int main() { }\n");
ASSERT_EQUALS("", errout.str());
check("int _tmain() { }\n");
ASSERT_EQUALS("", errout.str());
check("int WinMain() { }\n");
ASSERT_EQUALS("", errout.str());
}
void initializationIsNotAFunction()
{
check("struct B: N::A {\n"