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"))
|
if (Token::Match(tok2, "static|virtual"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// don't warn if type is LP..
|
// don't warn for unknown types..
|
||||||
if (tok2->str().compare(0, 2, "LP") == 0)
|
// LPVOID, HDC, etc
|
||||||
continue;
|
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?
|
// member function?
|
||||||
if (isMemberFunc(tok2))
|
if (isMemberFunc(tok2))
|
||||||
|
|
|
@ -3256,6 +3256,12 @@ private:
|
||||||
" LPVOID a() { return 0; };\n"
|
" LPVOID a() { return 0; };\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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