File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1186,7 +1186,13 @@ void CheckUnusedVar::checkFunctionVariableUsage()
11861186 const Token* lambdaOrInlineStart{};
11871187 const bool hasLambdaOrInline = scope->hasInlineOrLambdaFunction (&lambdaOrInlineStart);
11881188
1189+ const Token *nextStructuredBindingTok = nullptr ;
1190+
11891191 for (const Token *tok = scope->bodyStart ; tok != scope->bodyEnd ; tok = tok->next ()) {
1192+ if (nextStructuredBindingTok)
1193+ tok = nextStructuredBindingTok;
1194+ nextStructuredBindingTok = nullptr ;
1195+
11901196 if (findLambdaEndToken (tok))
11911197 // todo: handle lambdas
11921198 break ;
@@ -1196,6 +1202,15 @@ void CheckUnusedVar::checkFunctionVariableUsage()
11961202 const Token *varDecl = nullptr ;
11971203 if (tok->variable () && tok->variable ()->nameToken () == tok) {
11981204 const Token * eq = tok->next ();
1205+ if (isStructuredBindingVariable (tok->variable ())) {
1206+ while (!Token::simpleMatch (eq, " ]" )) {
1207+ eq = eq->next ();
1208+ if (eq->variable ())
1209+ nextStructuredBindingTok = eq;
1210+ }
1211+ if (eq)
1212+ eq = eq->next ();
1213+ }
11991214 while (Token::simpleMatch (eq, " [" ))
12001215 eq = eq->link ()->next ();
12011216 if (Token::simpleMatch (eq, " ) (" ) && Token::simpleMatch (eq->linkAt (1 ), " ) =" ))
You can’t perform that action at this time.
0 commit comments