diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 16f637dd2..69304569f 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -667,7 +667,11 @@ static void compilePrecedence3(Token *&tok, AST_state& state) tok = tok->link(); tok = tok->next(); } - if (tok->str() == "[" || tok->str() == "(") + if (Token::Match(tok, "( %type% ) (")) { + state.op.push(tok->next()); + tok = tok->tokAt(3); + compileBinOp(tok, state, compilePrecedence2); + } else if (tok->str() == "[" || tok->str() == "(") compilePrecedence2(tok, state); compileUnaryOp(tok2, state, nullptr); } else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2e162ba4e..be10d1d4d 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8378,6 +8378,10 @@ private: ASSERT_EQUALS("adelete", testAst("delete (a);")); ASSERT_EQUALS("adelete", testAst("delete[] a;")); ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);")); + + // clang testsuite.. + ASSERT_EQUALS("const0(new", testAst("new const auto (0);")); + ASSERT_EQUALS("auto0.0(new", testAst("new (auto) (0.0);")); } void astpar() const { // parentheses