Fixed #1426 (false positive: returning LPVOID can be const)
This commit is contained in:
parent
459a3bac50
commit
d5611a1a06
|
@ -1489,6 +1489,10 @@ void CheckClass::checkConst()
|
||||||
if (Token::Match(tok2, "static|virtual"))
|
if (Token::Match(tok2, "static|virtual"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// don't warn if type is LP..
|
||||||
|
if (tok2->str().compare(0,2,"LP") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
// member function?
|
// member function?
|
||||||
if (Token::Match(tok2, "%type% %var% (") ||
|
if (Token::Match(tok2, "%type% %var% (") ||
|
||||||
Token::Match(tok2, "%type% %type% %var% (") ||
|
Token::Match(tok2, "%type% %type% %var% (") ||
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
TEST_CASE(constincdec); // increment/decrement => non-const
|
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||||
TEST_CASE(constReturnReference);
|
TEST_CASE(constReturnReference);
|
||||||
TEST_CASE(constDelete); // delete member variable => not const
|
TEST_CASE(constDelete); // delete member variable => not const
|
||||||
|
TEST_CASE(constLPVOID); // a function that returns LPVOID can't be const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the operator Equal
|
// Check the operator Equal
|
||||||
|
@ -1797,6 +1798,15 @@ private:
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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)
|
REGISTER_TEST(TestClass)
|
||||||
|
|
Loading…
Reference in New Issue