fix #2692 (False positive: if parsed as function in operator >>)

This commit is contained in:
Robert Reif 2011-03-28 20:02:06 -04:00
parent 1aca09a8bf
commit e9a23d9cb5
2 changed files with 13 additions and 1 deletions

View File

@ -9578,7 +9578,7 @@ void Tokenizer::simplifyOperatorName()
par = par->next();
done = false;
}
if (Token::Match(par, "[<>+-*&/=.!]") || Token::Match(par, "==|!=|<=|>="))
if (Token::Match(par, "[<>+-*&/=.!]") || Token::Match(par, "==|!=|<=|>=|>>|<<"))
{
op += par->str();
par = par->next();

View File

@ -323,6 +323,7 @@ private:
TEST_CASE(simplifyOperatorName2);
TEST_CASE(simplifyOperatorName3);
TEST_CASE(simplifyOperatorName4);
TEST_CASE(simplifyOperatorName5);
// Some simple cleanups of unhandled macros in the global scope
TEST_CASE(removeMacrosInGlobalScope);
@ -5617,6 +5618,17 @@ private:
ASSERT_EQUALS(result, tokenizeAndStringify(code,false));
}
void simplifyOperatorName5()
{
const char code1[] = "std::istream & operator >> (std::istream & s, Fred &f);";
const char result1[] = "std :: istream & operator>> ( std :: istream & s , Fred & f ) ;";
ASSERT_EQUALS(result1, tokenizeAndStringify(code1,false));
const char code2[] = "std::ostream & operator << (std::ostream & s, const Fred &f);";
const char result2[] = "std :: ostream & operator<< ( std :: ostream & s , const Fred & f ) ;";
ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false));
}
void removeMacrosInGlobalScope()
{
// remove some unhandled macros in the global scope.