diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7efa0e120..223bd315a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1167,6 +1167,26 @@ void Tokenizer::simplifyTypedef() } } + // check for operator typedef + /** @todo add support for multi-token operators */ + else if (tok2->str() == "operator" && + tok2->next()->str() == typeName->str() && + tok2->strAt(2) == "(" && + Token::Match(tok2->tokAt(2)->link(), ") const| {")) + { + // check for qualifier + if (tok2->previous()->str() == "::") + { + // check for available and matching class name + if (!spaceInfo.empty() && classLevel < spaceInfo.size() && + tok2->strAt(-2) == spaceInfo[classLevel].className) + { + tok2 = tok2->next(); + simplifyType = true; + } + } + } + // check for member functions else if (Token::Match(tok2, ") const| {")) { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 3c06af1c6..5ab28c14f 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -4751,7 +4751,7 @@ private: "operator int * * ( ) const ; " "} ; " "Fred :: operator int * * ( ) const { }"; - TODO_ASSERT_EQUALS(expected, sizeof_(code)); + ASSERT_EQUALS(expected, sizeof_(code)); ASSERT_EQUALS("", errout.str()); } }