diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index d8048af2ee3..3062451449a 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -746,7 +746,7 @@ static void compileTerm(Token *&tok, AST_state& state) tok = tok->next(); } while (Token::Match(tok, "%name%|%str%")); } else if (tok->isName()) { - if (Token::Match(tok, "return|case") || (state.cpp && tok->str() == "throw")) { + if (Token::Match(tok, "return|case") || (state.cpp && (tok->str() == "throw" || Token::simpleMatch(tok->tokAt(-1), ":: new")))) { if (tok->str() == "case") state.inCase = true; const bool tokIsReturn = tok->str() == "return"; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f6a0a67f4eb..2d4f514f99d 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6220,6 +6220,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("pint0{new=", testAst("p = new int*{ 0 };")); ASSERT_EQUALS("pint5[{new=", testAst("p = new int* [5]{};")); ASSERT_EQUALS("pint5[0{new=", testAst("p = new int* [5]{ 0 };")); + ASSERT_EQUALS("sSint(new::(new=", testAst("s = new S(::new int());")); // #12502 // placement new ASSERT_EQUALS("X12,3,(new ab,c,", testAst("new (a,b,c) X(1,2,3);"));