diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9b4a392a5..354daf99e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10839,7 +10839,7 @@ void Tokenizer::simplifyOperatorName() return; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (Token::Match(tok, "using|:: operator %op% ;")) { + if (Token::Match(tok, "using|:: operator %op%|%name% ;")) { tok->next()->str("operator" + tok->strAt(2)); tok->next()->deleteNext(); continue; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7ea814a3c..f371af934 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -399,6 +399,7 @@ private: TEST_CASE(simplifyOperatorName12); // #9110 TEST_CASE(simplifyOperatorName13); // user defined literal TEST_CASE(simplifyOperatorName14); // std::complex operator "" if + TEST_CASE(simplifyOperatorName15); // ticket #9468 syntaxError TEST_CASE(simplifyNullArray); @@ -6378,6 +6379,21 @@ private: } } + void simplifyOperatorName15() { // ticket #9468 syntaxError + const char code[] = "template struct a;" + "template struct b {" + " typedef char c;" + " operator c();" + "};" + "template <> struct a : b { using b::operator char; };"; + ASSERT_EQUALS("struct a ; template < typename > struct a ; " + "struct b ; " + "struct a : b { using b :: operatorchar ; } ; struct b { " + "operatorchar ( ) ; " + "} ;", + tokenizeAndStringify(code)); + } + void simplifyNullArray() { ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;")); }