From d23fb873cca66a02d22878a88a031f104aeff77d Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sat, 6 Aug 2011 17:54:02 -0400 Subject: [PATCH] fix #2970 (Incorrect report: Class does not have a constructor) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d76757589..9f2535e32 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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() + "::"; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index c03d197d4..4cf1064ce 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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() { {