From 32bf53eeda35fd674c0799d31159579be305471c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 10 Apr 2020 14:01:15 +0200 Subject: [PATCH] Fixed #9221 (False positive when using an array of lists) --- lib/checkclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 16542edd8..399a83e8f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2047,7 +2047,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool& if (lhs->previous()->variable()->typeStartToken()->strAt(-1) != "const" && lhs->previous()->variable()->isPointer()) return false; } - } else if (lhs->str() == ":" && lhs->astParent() && lhs->astParent()->str() == "(" && tok1->strAt(1) == ")") { // range-based for-loop (C++11) + } else if (lhs->str() == ":" && lhs->astParent() && lhs->astParent()->str() == "(") { // range-based for-loop (C++11) // TODO: We could additionally check what is done with the elements to avoid false negatives. Here we just rely on "const" keyword being used. if (lhs->astParent()->strAt(1) != "const") return false;