Fixed #1426 (false positive: returning LPVOID can be const)

This commit is contained in:
Daniel Marjamäki 2010-02-21 10:19:28 +01:00
parent 459a3bac50
commit d5611a1a06
2 changed files with 14 additions and 0 deletions

View File

@ -1489,6 +1489,10 @@ void CheckClass::checkConst()
if (Token::Match(tok2, "static|virtual"))
continue;
// don't warn if type is LP..
if (tok2->str().compare(0,2,"LP") == 0)
continue;
// member function?
if (Token::Match(tok2, "%type% %var% (") ||
Token::Match(tok2, "%type% %type% %var% (") ||

View File

@ -90,6 +90,7 @@ private:
TEST_CASE(constincdec); // increment/decrement => non-const
TEST_CASE(constReturnReference);
TEST_CASE(constDelete); // delete member variable => not const
TEST_CASE(constLPVOID); // a function that returns LPVOID can't be const
}
// Check the operator Equal
@ -1797,6 +1798,15 @@ private:
"};\n");
ASSERT_EQUALS("", errout.str());
}
// A function that returns LPVOID can't be const
void constLPVOID()
{
checkConst("class Fred {\n"
" LPVOID a() { return 0; };\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)