From 40963100c4b2b8badfe07cec589ac99e3fa66998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 4 Dec 2020 20:29:10 +0100 Subject: [PATCH] Avoid functionStatic FP when there is #ifdef in function --- lib/checkclass.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index f811bc68f..d0c464d49 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1985,6 +1985,9 @@ static const std::set stl_containers_not_const = { "map", "unordere bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool& memberAccessed) const { + if (mTokenizer->hasIfdef(func->functionScope->bodyStart, func->functionScope->bodyEnd)) + return false; + // if the function doesn't have any assignment nor function call, // it can be a const function.. for (const Token *tok1 = func->functionScope->bodyStart; tok1 && tok1 != func->functionScope->bodyEnd; tok1 = tok1->next()) {