Tokenizer: Fix syntax error when operator* is called
This commit is contained in:
parent
8c57055a0b
commit
06cb0e99d1
|
@ -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;
|
||||
|
|
|
@ -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;"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue