From ee04c1bfb7da95483d309c612af8456007a8c20b Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 12 Oct 2011 09:10:34 -0400 Subject: [PATCH] fix #3194 (Parsing glitch causes false 'can be const' error for an 'if' statement) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 620f3db49..8be09a51e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1d919dec8..323029b4a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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.