From 771dc2e1ad51f3c3a3d08efbb7e838dfd1d78428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 27 Nov 2013 06:17:00 +0100 Subject: [PATCH] AST: Improved handling when calling function through function pointer hidden within parantheses '(a.f)(1,2)' --- lib/tokenlist.cpp | 8 ++++++++ test/testtokenize.cpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index d08964fd4..667ae4c22 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -479,6 +479,14 @@ static void compileTerm(Token *& tok, std::stack &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(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2f6b1751d..e5b45ec0e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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;"));