From 489fc6cce7655fcd33f6fd4da703272a00b67a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 11 Oct 2014 13:20:48 +0200 Subject: [PATCH] AST: more fixes of new statements in clang test suite. some of it is not handled very well. --- lib/tokenlist.cpp | 4 +++- test/testtokenize.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index fed2e2f20..49eb774db 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -660,12 +660,14 @@ static void compilePrecedence3(Token *&tok, AST_state& state) Token* newtok = tok; tok = tok->next(); if (tok->str() == "(") { - if (Token::Match(tok, "( %var% ) ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") (")) + if (Token::Match(tok, "( &| %var%") && Token::Match(tok->link(), ") ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") (")) tok = tok->link()->next(); if (Token::Match(tok->link(), ") %type%")) tok = tok->link()->next(); else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [(;]")) tok = tok->next(); + else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") (")) + tok = tok->next(); } state.op.push(tok); while (Token::Match(tok, "%var%|*|&|<")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d29a878be..1936428b9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8391,6 +8391,9 @@ private: ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();")); ASSERT_EQUALS("pSnew=", testAst("p=new (x)(S)(1,2);")); ASSERT_EQUALS("inti[new(", testAst("(void)new (int[i]);")); + ASSERT_EQUALS("intp* pnew malloc4(", testAst("int*p; new (p) (malloc(4));")); + ASSERT_EQUALS("intnew", testAst("new (&w.x)(int*)(0);")); + ASSERT_EQUALS("&new", testAst("new (&w.x)(0);")); // <- the "(int*)" has been simplified } void astpar() const { // parentheses