From 649e2dfa97df74049cda3f6258729067d4bf0c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 12 Oct 2014 11:12:25 +0200 Subject: [PATCH] AST: fixed ast for 'a = new (b) ::X;' --- lib/tokenlist.cpp | 4 ++-- test/testtokenize.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index ce8fa858b..1fe2b4364 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -662,7 +662,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state) if (tok->str() == "(") { 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%")) + if (Token::Match(tok->link(), ") ::| %type%")) tok = tok->link()->next(); else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [();,]")) tok = tok->next(); @@ -670,7 +670,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state) tok = tok->next(); } state.op.push(tok); - while (Token::Match(tok, "%var%|*|&|<")) { + while (Token::Match(tok, "%var%|*|&|<|::")) { if (tok->link()) tok = tok->link(); tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b985d22bc..157e8992c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8393,11 +8393,12 @@ private: ASSERT_EQUALS("adelete", testAst("delete (a);")); ASSERT_EQUALS("adelete", testAst("delete[] a;")); ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);")); + ASSERT_EQUALS("a::new=", testAst("a = new (b) ::X;")); // clang testsuite.. ASSERT_EQUALS("const0(new", testAst("new const auto (0);")); ASSERT_EQUALS("autonew", testAst("new (auto) (0.0);")); - ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();")); + ASSERT_EQUALS("int3[4[5[new", 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));"));