diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 3b10fa31b..8a6d06c27 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1117,7 +1117,7 @@ void CheckClass::operatorEq() std::list::const_iterator func; for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func) { - if (func->type == Function::eOperatorEqual && func->access != Private) { + if (func->type == Function::eOperatorEqual && func->access == Public) { // skip "deleted" functions - cannot be called anyway if (func->isDelete) continue; diff --git a/test/testclass.cpp b/test/testclass.cpp index 09b24ddfc..b8a594b0b 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -572,6 +572,13 @@ private: "};"); ASSERT_EQUALS("", errout.str()); + checkOpertorEq("class A\n" + "{\n" + "protected:\n" + " void operator=(const A&);\n" + "};"); + ASSERT_EQUALS("", errout.str()); + checkOpertorEq("class A\n" "{\n" "private:\n"