Fixed #10079 (AST: switch does not have two operands)

This commit is contained in:
Daniel Marjamäki 2021-05-04 20:15:44 +02:00
parent f0005665a8
commit b8de69489d
2 changed files with 8 additions and 0 deletions

View File

@ -1383,6 +1383,7 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
if (tok->str() == "(")
tok = tok->astOperand1();
const Token * const endToken2 = tok->link();
tok = tok->next();
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
tok = createAstAtToken(tok, cpp);
}

View File

@ -6011,6 +6011,13 @@ private:
// #9729
ASSERT_NO_THROW(tokenizeAndStringify("void foo() { bar([]() noexcept { if (0) {} }); }"));
// #10079 - createInnerAST bug..
ASSERT_EQUALS("x{([= yz= switchy(",
testAst("x = []() -> std::vector<uint8_t> {\n"
" const auto y = z;\n"
" switch (y) {}\n"
"};"));
}
void astcase() {