AST: Improved handling when calling function through function pointer hidden within parantheses '(a.f)(1,2)'

This commit is contained in:
Daniel Marjamäki 2013-11-27 06:17:00 +01:00
parent 3b11ee9e0e
commit 771dc2e1ad
2 changed files with 10 additions and 0 deletions

View File

@ -479,6 +479,14 @@ static void compileTerm(Token *& tok, std::stack<Token*> &op)
} else if (Token::Match(tok,"( {")) {
op.push(tok->next());
tok = tok->link()->next();
} else if (Token::simpleMatch(tok->link(),") (")) {
// Parenthesized sub-expression
Token *nextpar = tok->link()->next();
tok = tok->next();
compileExpression(tok,op);
tok = nextpar;
compileBinOp(tok, compileExpression, op);
tok = tok->next();
} else {
// Parenthesized sub-expression
tok = tok->next();

View File

@ -10016,6 +10016,8 @@ private:
ASSERT_EQUALS("123+*4*", testAst("1*(2+3)*4"));
ASSERT_EQUALS("ifab.c&d==(", testAst("if((a.b&c)==d){}"));
ASSERT_EQUALS("pf.pf.12,(&&", testAst("((p.f) && (p.f)(1,2))"));
// casts
ASSERT_EQUALS("a1(2(+=",testAst("a=(t)1+(t)2;"));
ASSERT_EQUALS("a1(2+=",testAst("a=(t)1+2;"));