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 += ")";
par = par->next();
if (Token::simpleMatch(par, "...")) {
op.clear();
par = nullptr;
break;
}
done = false;
} else if (Token::Match(par, "\"\" %name% (|;|<")) {
op += "\"\"";

View File

@ -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<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() {
const char code[] = "struct S { void operator()(int); };\n"
"\n"