Skip to content

Commit

Permalink
Fix #12502 error: Cyclic reverse analysis with scoped new (#6133)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Mar 17, 2024
1 parent e2b4b3c commit 967323e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);"));
Expand Down

0 comments on commit 967323e

Please sign in to comment.