Fixed #8746 (Syntax error, AST broken (using a::operator=))
This commit is contained in:
parent
1bb1c4cc8e
commit
523a9c1c4a
|
@ -9765,7 +9765,22 @@ void Tokenizer::simplifyOperatorName()
|
|||
if (isC())
|
||||
return;
|
||||
|
||||
bool isUsingStmt = false;
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (tok->str() == ";") {
|
||||
if (isUsingStmt && Token::Match(tok->tokAt(-3), "using|:: operator %op% ;")) {
|
||||
tok->previous()->previous()->str("operator" + tok->previous()->str());
|
||||
tok->deletePrevious();
|
||||
}
|
||||
isUsingStmt = false;
|
||||
continue;
|
||||
}
|
||||
if (tok->str() == "using") {
|
||||
isUsingStmt = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok->str() != "operator")
|
||||
continue;
|
||||
// operator op
|
||||
|
@ -9783,18 +9798,15 @@ void Tokenizer::simplifyOperatorName()
|
|||
par = par->next();
|
||||
}
|
||||
done = false;
|
||||
}
|
||||
if (Token::Match(par, ".|%op%|,")) {
|
||||
} else if (Token::Match(par, ".|%op%|,")) {
|
||||
op += par->str();
|
||||
par = par->next();
|
||||
done = false;
|
||||
}
|
||||
if (Token::simpleMatch(par, "[ ]")) {
|
||||
} else if (Token::simpleMatch(par, "[ ]")) {
|
||||
op += "[]";
|
||||
par = par->tokAt(2);
|
||||
done = false;
|
||||
}
|
||||
if (Token::Match(par, "( *| )")) {
|
||||
} else if (Token::Match(par, "( *| )")) {
|
||||
// break out and simplify..
|
||||
if (operatorEnd(par->next()))
|
||||
break;
|
||||
|
|
|
@ -391,6 +391,7 @@ private:
|
|||
TEST_CASE(simplifyOperatorName7); // ticket #4619
|
||||
TEST_CASE(simplifyOperatorName8); // ticket #5706
|
||||
TEST_CASE(simplifyOperatorName9); // ticket #5709 - comma operator not properly tokenized
|
||||
TEST_CASE(simplifyOperatorName10); // #8746 - using a::operator=
|
||||
|
||||
TEST_CASE(simplifyNullArray);
|
||||
|
||||
|
@ -6123,6 +6124,11 @@ private:
|
|||
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyOperatorName10() { // #8746
|
||||
const char code[] = "using a::operator=;";
|
||||
ASSERT_EQUALS("using a :: operator= ;", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyNullArray() {
|
||||
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue