Fixed #10080 (syntax error: operator)

This commit is contained in:
Daniel Marjamäki 2021-01-14 20:56:11 +01:00
parent 56124f0c5d
commit a5babf25a7
2 changed files with 14 additions and 0 deletions

View File

@ -11384,6 +11384,11 @@ void Tokenizer::simplifyOperatorName()
} }
op += ")"; op += ")";
par = par->next(); par = par->next();
if (Token::simpleMatch(par, "...")) {
op.clear();
par = nullptr;
break;
}
done = false; done = false;
} else if (Token::Match(par, "\"\" %name% (|;|<")) { } else if (Token::Match(par, "\"\" %name% (|;|<")) {
op += "\"\""; op += "\"\"";

View File

@ -427,6 +427,7 @@ private:
TEST_CASE(simplifyOperatorName25); TEST_CASE(simplifyOperatorName25);
TEST_CASE(simplifyOperatorName26); TEST_CASE(simplifyOperatorName26);
TEST_CASE(simplifyOperatorName27); TEST_CASE(simplifyOperatorName27);
TEST_CASE(simplifyOperatorName28);
TEST_CASE(simplifyOverloadedOperators1); TEST_CASE(simplifyOverloadedOperators1);
TEST_CASE(simplifyOverloadedOperators2); // (*this)(123) TEST_CASE(simplifyOverloadedOperators2); // (*this)(123)
@ -6737,6 +6738,14 @@ private:
tokenizeAndStringify(code)); tokenizeAndStringify(code));
} }
void simplifyOperatorName28() {
const char code[] = "template<class... Ts> 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() { void simplifyOverloadedOperators1() {
const char code[] = "struct S { void operator()(int); };\n" const char code[] = "struct S { void operator()(int); };\n"
"\n" "\n"