fix #2609 (False positive on template dependent name)

This commit is contained in:
Robert Reif 2011-02-24 06:39:46 -05:00
parent 39114e3482
commit 26152a9264
2 changed files with 15 additions and 3 deletions

View File

@ -9382,7 +9382,8 @@ void Tokenizer::removeUnnecessaryQualification()
classInfo.pop(); classInfo.pop();
else if (tok->str() == classInfo.top().className && else if (tok->str() == classInfo.top().className &&
Token::Match(tok, "%type% :: %type% (") && Token::Match(tok, "%type% :: %type% (") &&
Token::Match(tok->tokAt(3)->link(), ") const| {|;")) Token::Match(tok->tokAt(3)->link(), ") const| {|;") &&
tok->previous()->str() != ":")
{ {
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList; std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
ErrorLogger::ErrorMessage::FileLocation loc; ErrorLogger::ErrorMessage::FileLocation loc;

View File

@ -328,7 +328,8 @@ private:
TEST_CASE(simplifyFunctionReturn); TEST_CASE(simplifyFunctionReturn);
TEST_CASE(removeUnnecessaryQualification); TEST_CASE(removeUnnecessaryQualification1);
TEST_CASE(removeUnnecessaryQualification2);
TEST_CASE(simplifyIfNotNull); TEST_CASE(simplifyIfNotNull);
} }
@ -6550,7 +6551,7 @@ private:
ASSERT_EQUALS(expected, tok(code, false)); ASSERT_EQUALS(expected, tok(code, false));
} }
void removeUnnecessaryQualification() void removeUnnecessaryQualification1()
{ {
const char code[] = "class Fred { Fred::Fred() {} };"; const char code[] = "class Fred { Fred::Fred() {} };";
const char expected[] = "class Fred { Fred ( ) { } } ;"; const char expected[] = "class Fred { Fred ( ) { } } ;";
@ -6558,6 +6559,16 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str()); ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
} }
void removeUnnecessaryQualification2()
{
const char code[] = "template<typename Iter, typename Skip>\n"
"struct grammar : qi::grammar<Iter, int(), Skip> {\n"
" grammar() : grammar::base_type(start) { }\n"
"};\n";
tok(code, false);
ASSERT_EQUALS("", errout.str());
}
void simplifyIfNotNull() // ticket # 2601 segmentation fault void simplifyIfNotNull() // ticket # 2601 segmentation fault
{ {
const char code[] = "|| #if #define <="; const char code[] = "|| #if #define <=";