Skip to content

Commit 1526601

Browse files
committed
Fix #11861 Syntax Error: AST broken for C++20 ranges
1 parent 2285c1d commit 1526601

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

lib/tokenlist.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,8 @@ static Token * createAstAtToken(Token *tok)
16961696
tok->next()->astOperand1(tok);
16971697
tok->next()->astOperand2(colon);
16981698

1699+
createAstAtTokenInner(colon, tok->linkAt(1), cpp);
1700+
16991701
return decl;
17001702
}
17011703
}

test/testtokenize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6662,6 +6662,7 @@ class TestTokenizer : public TestFixture {
66626662
ASSERT_EQUALS("foria:( asize.(", testAst("for(decltype(a.size()) i:a);"));
66636663
ASSERT_EQUALS("forec0{([,(:( fb.return", testAst("for (auto e : c(0, [](auto f) { return f->b; }));")); // #10802
66646664
ASSERT_EQUALS("forvar1{;;(", testAst("for(int var{1};;)")); // #12867
6665+
ASSERT_EQUALS("forxg{([(:( si.return", testAst("for (auto [x] : g([](S s) { return s.i; })) {}")); // #11861
66656666

66666667
// for with initializer (c++20)
66676668
ASSERT_EQUALS("forab=ca:;(", testAst("for(a=b;int c:a)"));

0 commit comments

Comments
 (0)