AST: Fix AST when returning list of lambda functions
This commit is contained in:
parent
3699227b12
commit
cf1dd2e6f6
|
@ -1176,7 +1176,7 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
|
|||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
} else if (tok->str() == "[") {
|
||||
} else if (cpp && tok->str() == "[") {
|
||||
if (isLambdaCaptureList(tok)) {
|
||||
tok = tok->astOperand1();
|
||||
if (tok->str() == "(")
|
||||
|
@ -1184,6 +1184,11 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
|
|||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
} else if (Token::simpleMatch(tok->link(), "] (") && Token::simpleMatch(tok->link()->linkAt(1), ") {")) {
|
||||
tok = tok->link()->linkAt(1)->next();
|
||||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7606,6 +7606,13 @@ private:
|
|||
|
||||
// 8628
|
||||
ASSERT_EQUALS("f{([( switchx( 1case y++", testAst("f([](){switch(x){case 1:{++y;}}});"));
|
||||
|
||||
ASSERT_EQUALS("{return ab=",
|
||||
testAst("return {\n"
|
||||
" [=]() {\n"
|
||||
" a = b;\n"
|
||||
" }\n"
|
||||
"};\n"));
|
||||
}
|
||||
|
||||
void astcase() {
|
||||
|
|
Loading…
Reference in New Issue