diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 304ed67cb..6c78aba93 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5114,15 +5114,17 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_ } else continue; } else if (tok->str() == "(") { - for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) { - if (isCPP() && Token::Match(tok2, "[(,] [")) { - // lambda function at tok2->next() - // find start of lambda body - Token * lambdaBody = tok2; - while (lambdaBody && lambdaBody != tok2->link() && lambdaBody->str() != "{") - lambdaBody = lambdaBody->next(); - if (lambdaBody && lambdaBody != tok2->link() && lambdaBody->link()) - simplifyVarDecl(lambdaBody, lambdaBody->link()->next(), only_k_r_fpar); + if (isCPP()) { + for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) { + if (Token::Match(tok2, "[(,] [")) { + // lambda function at tok2->next() + // find start of lambda body + Token * lambdaBody = tok2; + while (lambdaBody && lambdaBody != tok2->link() && lambdaBody->str() != "{") + lambdaBody = lambdaBody->next(); + if (lambdaBody && lambdaBody != tok2->link() && lambdaBody->link()) + simplifyVarDecl(lambdaBody, lambdaBody->link()->next(), only_k_r_fpar); + } } } tok = tok->link();