From a5babf25a76630c2f3242392153156295005ff09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 14 Jan 2021 20:56:11 +0100 Subject: [PATCH] Fixed #10080 (syntax error: operator) --- lib/tokenize.cpp | 5 +++++ test/testtokenize.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d3f8732a5..5666f91f8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -11384,6 +11384,11 @@ void Tokenizer::simplifyOperatorName() } op += ")"; par = par->next(); + if (Token::simpleMatch(par, "...")) { + op.clear(); + par = nullptr; + break; + } done = false; } else if (Token::Match(par, "\"\" %name% (|;|<")) { op += "\"\""; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 98ef5f06d..cca6c3231 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -427,6 +427,7 @@ private: TEST_CASE(simplifyOperatorName25); TEST_CASE(simplifyOperatorName26); TEST_CASE(simplifyOperatorName27); + TEST_CASE(simplifyOperatorName28); TEST_CASE(simplifyOverloadedOperators1); TEST_CASE(simplifyOverloadedOperators2); // (*this)(123) @@ -6737,6 +6738,14 @@ private: tokenizeAndStringify(code)); } + void simplifyOperatorName28() { + const char code[] = "template struct overloaded : Ts... { using Ts::operator()...; };\n" + "int main() { }"; + ASSERT_EQUALS("template < class ... Ts > struct overloaded : Ts ... { using Ts :: operator ( ) ... ; } ;\n" + "int main ( ) { }", + tokenizeAndStringify(code)); + } + void simplifyOverloadedOperators1() { const char code[] = "struct S { void operator()(int); };\n" "\n"