9185: Don't syntax error on nested lambdas (#2672)

This commit is contained in:
Ken-Patrick Lehrmann 2020-06-07 08:58:12 +02:00 committed by GitHub
parent 91b4d6950b
commit a45c7752a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -9460,7 +9460,7 @@ void Tokenizer::findGarbageCode() const
// Inside [] there can't be ; or various keywords // Inside [] there can't be ; or various keywords
else if (tok->str() == "[") { else if (tok->str() == "[") {
for (const Token* inner = tok->next(); inner != tok->link(); inner = inner->next()) { for (const Token* inner = tok->next(); inner != tok->link(); inner = inner->next()) {
if (Token::Match(inner, "(|[")) if (Token::Match(inner, "(|[|{"))
inner = inner->link(); inner = inner->link();
else if (Token::Match(inner, ";|goto|return|typedef")) else if (Token::Match(inner, ";|goto|return|typedef"))
syntaxError(inner); syntaxError(inner);

View File

@ -8306,6 +8306,10 @@ private:
"a c{[] {\n" "a c{[] {\n"
" if (0) {}\n" " if (0) {}\n"
"}};\n")); "}};\n"));
// #9185
ASSERT_NO_THROW(tokenizeAndStringify("void a() {\n"
" [b = [] { ; }] {};\n"
"}\n"));
} }
void checkIfCppCast() { void checkIfCppCast() {
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n" ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"