typedef: fix testcase 4. ticket: #2375

This commit is contained in:
Robert Reif 2011-01-04 07:39:41 +01:00 committed by Daniel Marjamäki
parent 63ad1fbe69
commit a782d3ddf7
2 changed files with 21 additions and 1 deletions

View File

@ -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 // check for member functions
else if (Token::Match(tok2, ") const| {")) else if (Token::Match(tok2, ") const| {"))
{ {

View File

@ -4751,7 +4751,7 @@ private:
"operator int * * ( ) const ; " "operator int * * ( ) const ; "
"} ; " "} ; "
"Fred :: operator int * * ( ) const { }"; "Fred :: operator int * * ( ) const { }";
TODO_ASSERT_EQUALS(expected, sizeof_(code)); ASSERT_EQUALS(expected, sizeof_(code));
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
} }