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()