Skip to content

Commit 731ef86

Browse files
Fix #11861 Syntax Error: AST broken for C++20 ranges (#8644)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent fb388e6 commit 731ef86

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
@@ -6701,6 +6701,7 @@ class TestTokenizer : public TestFixture {
67016701
ASSERT_EQUALS("foria:( asize.(", testAst("for(decltype(a.size()) i:a);"));
67026702
ASSERT_EQUALS("forec0{([,(:( fb.return", testAst("for (auto e : c(0, [](auto f) { return f->b; }));")); // #10802
67036703
ASSERT_EQUALS("forvar1{;;(", testAst("for(int var{1};;)")); // #12867
6704+
ASSERT_EQUALS("forxg{([(:( si.return", testAst("for (auto [x] : g([](S s) { return s.i; })) {}")); // #11861
67046705

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

0 commit comments

Comments
 (0)