fix #3127 ([False positive] _tmain function i VS 2010 project)
This commit is contained in:
parent
5e329d7280
commit
1dc7c0edf9
|
@ -161,7 +161,7 @@ void CheckUnusedFunctions::check(ErrorLogger * const errorLogger)
|
||||||
const FunctionUsage &func = it->second;
|
const FunctionUsage &func = it->second;
|
||||||
if (func.usedOtherFile || func.filename.empty())
|
if (func.usedOtherFile || func.filename.empty())
|
||||||
continue;
|
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;
|
continue;
|
||||||
if (! func.usedSameFile)
|
if (! func.usedSameFile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ private:
|
||||||
TEST_CASE(template1);
|
TEST_CASE(template1);
|
||||||
TEST_CASE(throwIsNotAFunction);
|
TEST_CASE(throwIsNotAFunction);
|
||||||
TEST_CASE(unusedError);
|
TEST_CASE(unusedError);
|
||||||
|
TEST_CASE(unusedMain);
|
||||||
TEST_CASE(initializationIsNotAFunction);
|
TEST_CASE(initializationIsNotAFunction);
|
||||||
|
|
||||||
TEST_CASE(multipleFiles); // same function name in multiple files
|
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());
|
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()
|
void initializationIsNotAFunction()
|
||||||
{
|
{
|
||||||
check("struct B: N::A {\n"
|
check("struct B: N::A {\n"
|
||||||
|
|
Loading…
Reference in New Issue