From c5368581d9eeccabb8cc3c0606500432b9bec308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 16 Sep 2009 20:07:03 +0200 Subject: [PATCH] Fixed by #675 (false positive: when operator is overloaded) --- src/checkclass.cpp | 2 +- test/testclass.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/checkclass.cpp b/src/checkclass.cpp index abd556d9c..0683885dc 100644 --- a/src/checkclass.cpp +++ b/src/checkclass.cpp @@ -130,7 +130,7 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses) varname = next->strAt(3); } - else if (Token::Match(next, "%type% %var% [")) + else if (Token::Match(next, "%type% %var% [") && next->next()->str() != "operator") { varname = next->strAt(1); } diff --git a/test/testclass.cpp b/test/testclass.cpp index c9f552d5a..8879de866 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -431,6 +431,16 @@ private: "};\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("class John\n" + "{\n" + "public:\n" + " John() { }\n" + "\n" + " double operator[](const unsigned long i);\n" + "};\n"); + + ASSERT_EQUALS("", errout.str()); } void uninitMissingFuncDef()