fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement)

This commit is contained in:
Robert Reif 2011-10-12 09:10:34 -04:00
parent af6a6f9c2d
commit ee04c1bfb7
2 changed files with 13 additions and 1 deletions

View File

@ -10985,7 +10985,7 @@ void Tokenizer::simplifyOperatorName()
par = par->next();
done = false;
}
if (Token::Match(par, "=|.|%op%"))
if (Token::Match(par, "=|.|++|--|%op%"))
{
op += par->str();
par = par->next();

View File

@ -348,6 +348,7 @@ private:
TEST_CASE(simplifyOperatorName3);
TEST_CASE(simplifyOperatorName4);
TEST_CASE(simplifyOperatorName5);
TEST_CASE(simplifyOperatorName6); // ticket #3194
// Some simple cleanups of unhandled macros in the global scope
TEST_CASE(removeMacrosInGlobalScope);
@ -5929,6 +5930,17 @@ private:
ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false));
}
void simplifyOperatorName6() // ticket #3195
{
const char code1[] = "value_type * operator ++ (int);";
const char result1[] = "value_type * operator++ ( int ) ;";
ASSERT_EQUALS(result1, tokenizeAndStringify(code1,false));
const char code2[] = "value_type * operator -- (int);";
const char result2[] = "value_type * operator-- ( int ) ;";
ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false));
}
void removeMacrosInGlobalScope()
{
// remove some unhandled macros in the global scope.