Tokenizer: Fix syntax error when operator* is called

This commit is contained in:
Daniel Marjamäki 2020-05-04 21:33:30 +02:00
parent 8c57055a0b
commit 06cb0e99d1
2 changed files with 14 additions and 0 deletions

View File

@ -11080,6 +11080,11 @@ void Tokenizer::simplifyOperatorName()
if (tok->str() != "operator")
continue;
// operator op
if (Token::Match(tok, "operator %op% (")) {
tok->str(tok->str() + tok->next()->str());
tok->deleteNext();
continue;
}
std::string op;
Token *par = tok->next();
bool done = false;

View File

@ -412,6 +412,7 @@ private:
TEST_CASE(simplifyOperatorName23);
TEST_CASE(simplifyOperatorName24);
TEST_CASE(simplifyOperatorName25);
TEST_CASE(simplifyOperatorName26);
TEST_CASE(simplifyNullArray);
@ -6602,6 +6603,14 @@ private:
tokenizeAndStringify(code));
}
void simplifyOperatorName26() {
const char code[] = "void foo() {"
" x = y.operator *().z[123];"
"}";
ASSERT_EQUALS("void foo ( ) { x = y . operator* ( ) . z [ 123 ] ; }",
tokenizeAndStringify(code));
}
void simplifyNullArray() {
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
}