Fix issue 9458: Crash with shadow variables in a lambda (#2406)
* Fix issue 9458: Crash with shadow variables in a lambda * Format
This commit is contained in:
parent
f554a71dea
commit
f9d33c07f8
|
@ -1665,9 +1665,9 @@ static void valueFlowReverse(TokenList *tokenlist,
|
||||||
const Token * const startToken = var->nameToken();
|
const Token * const startToken = var->nameToken();
|
||||||
|
|
||||||
for (Token *tok2 = tok->previous(); ; tok2 = tok2->previous()) {
|
for (Token *tok2 = tok->previous(); ; tok2 = tok2->previous()) {
|
||||||
if (!tok2 ||
|
if (!tok2 || tok2 == startToken ||
|
||||||
tok2 == startToken ||
|
(tok2->str() == "{" &&
|
||||||
(tok2->str() == "{" && tok2->scope()->type == Scope::ScopeType::eFunction)) {
|
(tok2->scope()->type == Scope::ScopeType::eFunction || tok2->scope()->type == Scope::ScopeType::eLambda))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4334,6 +4334,14 @@ private:
|
||||||
" state = x;\n"
|
" state = x;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
valueOfTok(code, "=");
|
valueOfTok(code, "=");
|
||||||
|
|
||||||
|
code = "void a() {\n"
|
||||||
|
" auto b = [b = 0] {\n"
|
||||||
|
" if (b) {\n"
|
||||||
|
" }\n"
|
||||||
|
" };\n"
|
||||||
|
"}\n";
|
||||||
|
valueOfTok(code, "0");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue