diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index deabefcd4..9dfb92c91 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9460,7 +9460,7 @@ void Tokenizer::findGarbageCode() const // Inside [] there can't be ; or various keywords else if (tok->str() == "[") { for (const Token* inner = tok->next(); inner != tok->link(); inner = inner->next()) { - if (Token::Match(inner, "(|[")) + if (Token::Match(inner, "(|[|{")) inner = inner->link(); else if (Token::Match(inner, ";|goto|return|typedef")) syntaxError(inner); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 30cef37ec..649cf58d3 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8306,6 +8306,10 @@ private: "a c{[] {\n" " if (0) {}\n" "}};\n")); + // #9185 + ASSERT_NO_THROW(tokenizeAndStringify("void a() {\n" + " [b = [] { ; }] {};\n" + "}\n")); } void checkIfCppCast() { ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"