From af29efbb05f3f4d588623b5f6ea3b64fb48db000 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Sat, 6 Jan 2024 15:30:54 +0100 Subject: [PATCH] Fix loop --- lib/checkclass.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index d64a7cc17d4..d1519d47d18 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2664,7 +2664,7 @@ void CheckClass::initializerListOrder() tok = tok->next(); // find all variable initializations in list - while (tok && tok != func->functionScope->bodyStart) { + for (; tok && tok != func->functionScope->bodyStart; tok = tok->next()) { if (Token::Match(tok, "%name% (|{")) { const Variable *var = scope->getVariable(tok->str()); if (var) @@ -2677,9 +2677,8 @@ void CheckClass::initializerListOrder() if (auto var2 = tok2->variable()) vars.back().initArgs.emplace_back(var2); } - tok = end->next(); - } else - tok = tok->next(); + tok = end; + } } for (int j = 0; j < vars.size(); j++) {