From 5ba0d448922dad67884cc5cd416b43e30843abf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 12 Sep 2024 16:16:55 +0200 Subject: [PATCH] add check for missing closing brace + remove redundant check --- lib/checkunusedvar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 6d100837c12..c8a165fa1ed 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1551,7 +1551,7 @@ void CheckUnusedVar::checkStructMemberUsage() // Check if the struct member variable is used anywhere in the file bool use = false; for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { - if (Token::Match(tok, "%name% {") && (!tok->previous() || !Token::Match(tok->previous(), "class|struct")) && tok->str() == scope.className) { + if (Token::Match(tok, "%name% {") && !Token::Match(tok->previous(), "class|struct") && tok->str() == scope.className && tok->linkAt(1)) { const Token *inner = tok->next()->astOperand2(); // Find number of initialized members in braced initalizer int initmembs = 0;