Fixed #1579 (False positive: function can be const when return type is unknown)
This commit is contained in:
parent
1328a57103
commit
d360c01675
|
@ -1562,9 +1562,27 @@ 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)
|
||||
// don't warn for unknown types..
|
||||
// LPVOID, HDC, etc
|
||||
if (tok2->isName())
|
||||
{
|
||||
bool allupper = true;
|
||||
const std::string s(tok2->str());
|
||||
for (std::string::size_type pos = 0; pos < s.size(); ++pos)
|
||||
{
|
||||
unsigned char ch = s[pos];
|
||||
if (ch != '_' &&
|
||||
!std::isupper(ch) &&
|
||||
!std::isdigit(ch))
|
||||
{
|
||||
allupper = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allupper)
|
||||
continue;
|
||||
}
|
||||
|
||||
// member function?
|
||||
if (isMemberFunc(tok2))
|
||||
|
|
|
@ -3256,6 +3256,12 @@ private:
|
|||
" LPVOID a() { return 0; };\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #1579 - HDC
|
||||
checkConst("class Fred {\n"
|
||||
" HDC a() { return 0; };\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue