Fix issue 9644: Token::astOperand1() cyclic dependency on valid C++ code (#2590)
* Remove check for lambda * Add test case
This commit is contained in:
parent
e0acd1abf8
commit
40e1e82a65
|
@ -1309,21 +1309,6 @@ 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 (const Token * lambdaEnd = findLambdaEndScope(tok)) {
|
||||
Token *bodyStart = lambdaEnd->link();
|
||||
if (Token::Match(bodyStart, ". %name%") && bodyStart->originalName() == "->") {
|
||||
bodyStart = bodyStart->next();
|
||||
while (Token::Match(bodyStart, "%name%|::"))
|
||||
bodyStart = bodyStart->next();
|
||||
if (Token::simpleMatch(bodyStart, "<") && Token::simpleMatch(bodyStart->link(), "> {"))
|
||||
bodyStart = bodyStart->link()->next();
|
||||
}
|
||||
if (Token::simpleMatch(bodyStart, "{")) {
|
||||
tok = bodyStart;
|
||||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8244,6 +8244,13 @@ private:
|
|||
"void e(\n"
|
||||
" int, a<void()> f = [] {});\n"))
|
||||
|
||||
// #9644
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("void a() {\n"
|
||||
" char b[]{};\n"
|
||||
" auto c = [](int d) {\n"
|
||||
" for (char e = 0; d;) {}\n"
|
||||
" };\n"
|
||||
"}\n"))
|
||||
// #9537
|
||||
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"
|
||||
" template <typename b> a(b) {}\n"
|
||||
|
|
Loading…
Reference in New Issue