fix #3151 (missing portability warning for extra qualifier on destructor)

This commit is contained in:
Robert Reif 2011-09-29 19:25:14 -04:00
parent 4d12372b65
commit ac942c6684
2 changed files with 14 additions and 1 deletions

View File

@ -10990,7 +10990,7 @@ void Tokenizer::removeUnnecessaryQualification()
classInfo.pop_back();
else if (tok->str() == classInfo.back().className &&
!classInfo.back().isNamespace && tok->previous()->str() != ":" &&
(Token::Match(tok, "%type% :: %type% (") ||
(Token::Match(tok, "%type% :: ~| %type% (") ||
Token::Match(tok, "%type% :: operator")))
{
int offset = 3;
@ -11011,6 +11011,8 @@ void Tokenizer::removeUnnecessaryQualification()
offset++;
}
}
else if (tok->strAt(2) == "~")
offset++;
if (Token::Match(tok->tokAt(offset)->link(), ") const| {|;|:"))
{

View File

@ -372,6 +372,7 @@ private:
TEST_CASE(removeUnnecessaryQualification6); // ticket #2859
TEST_CASE(removeUnnecessaryQualification7); // ticket #2970
TEST_CASE(removeUnnecessaryQualification8);
TEST_CASE(removeUnnecessaryQualification9); // ticket #3151
TEST_CASE(simplifyIfNotNull);
TEST_CASE(simplifyVarDecl1); // ticket # 2682 segmentation fault
@ -7361,6 +7362,16 @@ private:
"[test.cpp:5]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
}
void removeUnnecessaryQualification9()
{
const char code[] = "class Fred {\n"
"public:\n"
" Fred::~Fred();\n"
"};\n";
tok(code, false);
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
}
void simplifyIfNotNull()
{
{