From 26152a9264c12630ffe8f0c940d31b3d70335585 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 24 Feb 2011 06:39:46 -0500 Subject: [PATCH] fix #2609 (False positive on template dependent name) --- lib/tokenize.cpp | 3 ++- test/testsimplifytokens.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9fae3503c..e44fe681a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9382,7 +9382,8 @@ void Tokenizer::removeUnnecessaryQualification() classInfo.pop(); else if (tok->str() == classInfo.top().className && Token::Match(tok, "%type% :: %type% (") && - Token::Match(tok->tokAt(3)->link(), ") const| {|;")) + Token::Match(tok->tokAt(3)->link(), ") const| {|;") && + tok->previous()->str() != ":") { std::list locationList; ErrorLogger::ErrorMessage::FileLocation loc; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 35f0d4e34..a546b3654 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -328,7 +328,8 @@ private: TEST_CASE(simplifyFunctionReturn); - TEST_CASE(removeUnnecessaryQualification); + TEST_CASE(removeUnnecessaryQualification1); + TEST_CASE(removeUnnecessaryQualification2); TEST_CASE(simplifyIfNotNull); } @@ -6550,7 +6551,7 @@ private: ASSERT_EQUALS(expected, tok(code, false)); } - void removeUnnecessaryQualification() + void removeUnnecessaryQualification1() { const char code[] = "class Fred { 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()); } + void removeUnnecessaryQualification2() + { + const char code[] = "template\n" + "struct grammar : qi::grammar {\n" + " grammar() : grammar::base_type(start) { }\n" + "};\n"; + tok(code, false); + ASSERT_EQUALS("", errout.str()); + } + void simplifyIfNotNull() // ticket # 2601 segmentation fault { const char code[] = "|| #if #define <=";