diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6de8e5325..20e30ff3d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10815,7 +10815,7 @@ void Tokenizer::deleteSymbolDatabase() bool Tokenizer::operatorEnd(const Token * tok) const { if (tok && tok->str() == ")") { - if (isFunctionHead(tok, "{|;")) + if (isFunctionHead(tok, "{|;|?|:")) return true; tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 40447f8f3..ed9fce4fa 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -408,6 +408,7 @@ private: TEST_CASE(simplifyOperatorName21); TEST_CASE(simplifyOperatorName22); TEST_CASE(simplifyOperatorName23); + TEST_CASE(simplifyOperatorName24); TEST_CASE(simplifyNullArray); @@ -6547,6 +6548,19 @@ private: } } + void simplifyOperatorName24() { + { + const char code[] = "void foo() { int i = a.operator++() ? a.operator--() : 0; }"; + ASSERT_EQUALS("void foo ( ) { int i ; i = a . operator++ ( ) ? a . operator-- ( ) : 0 ; }", + tokenizeAndStringify(code)); + } + { + const char code[] = "void foo() { int i = a.operator++(0) ? a.operator--(0) : 0; }"; + ASSERT_EQUALS("void foo ( ) { int i ; i = a . operator++ ( 0 ) ? a . operator-- ( 0 ) : 0 ; }", + tokenizeAndStringify(code)); + } + } + void simplifyNullArray() { ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;")); }