fix #2970 (Incorrect report: Class does not have a constructor)

This commit is contained in:
Robert Reif 2011-08-06 17:54:02 -04:00
parent 3bd8bf0e75
commit d23fb873cc
2 changed files with 14 additions and 1 deletions

View File

@ -10044,7 +10044,7 @@ void Tokenizer::removeUnnecessaryQualification()
classInfo.pop_back();
else if (tok->str() == classInfo.back().className &&
Token::Match(tok, "%type% :: %type% (") &&
Token::Match(tok->tokAt(3)->link(), ") const| {|;") &&
Token::Match(tok->tokAt(3)->link(), ") const| {|;|:") &&
tok->previous()->str() != ":" && !classInfo.back().isNamespace)
{
std::string qualification = tok->str() + "::";

View File

@ -360,6 +360,7 @@ private:
TEST_CASE(removeUnnecessaryQualification4);
TEST_CASE(removeUnnecessaryQualification5);
TEST_CASE(removeUnnecessaryQualification6); // ticket #2859
TEST_CASE(removeUnnecessaryQualification7); // ticket #2970
TEST_CASE(simplifyIfNotNull);
TEST_CASE(simplifyVarDecl1); // ticket # 2682 segmentation fault
@ -7221,6 +7222,18 @@ private:
ASSERT_EQUALS("", errout.str());
}
void removeUnnecessaryQualification7() // ticket #2970
{
const char code[] = "class TProcedure {\n"
"public:\n"
" TProcedure::TProcedure(long endAddress) : m_lEndAddr(endAddress){}\n"
"private:\n"
" long m_lEndAddr;\n"
"}\n";
tok(code, false);
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'TProcedure::' unnecessary and considered an error by many compilers.\n", errout.str());
}
void simplifyIfNotNull()
{
{