Fixed #10403 (Wrong AST for destructor call)

This commit is contained in:
Daniel Marjamäki 2021-08-28 22:11:30 +02:00
parent 43fa7d2ebe
commit 0d31486264
2 changed files with 4 additions and 3 deletions

View File

@ -728,7 +728,7 @@ static void compileBinOp(Token *&tok, AST_state& state, void (*f)(Token *&tok, A
Token *binop = tok;
if (f) {
tok = tok->next();
if (Token::simpleMatch(binop, ":: ~"))
if (Token::Match(binop, "::|. ~"))
tok = tok->next();
state.depth++;
if (tok && state.depth <= AST_MAX_DEPTH)
@ -934,8 +934,8 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
state.op.push(tok);
tok = tok->tokAt(3);
break;
} else
compileBinOp(tok, state, compileScope);
}
compileBinOp(tok, state, compileScope);
} else if (tok->str() == "[") {
if (state.cpp && isPrefixUnary(tok, state.cpp) && Token::Match(tok->link(), "] (|{")) { // Lambda
// What we do here:

View File

@ -6133,6 +6133,7 @@ private:
ASSERT_EQUALS("abc{d{,{(=", testAst("a = b({ c{}, d{} });"));
ASSERT_EQUALS("abc;(", testAst("a(b;c)"));
ASSERT_EQUALS("x{( forbc;;(", testAst("x({ for(a;b;c){} });"));
ASSERT_EQUALS("PT.(", testAst("P->~T();")); // <- The "T" token::function() will be a destructor
}
void asttemplate() { // uninstantiated templates will have <,>,etc..