@@ -241,8 +241,8 @@ void CheckClass::checkExplicitConstructors()
241241 }
242242 }
243243
244- // Abstract classes can't be instantiated. But if there is "misuse" by derived
245- // classes then these constructors must be explicit.
244+ // Abstract classes can't be instantiated. But if there is C++11
245+ // "misuse" by derived classes then these constructors must be explicit.
246246 if (isAbstractClass && _settings->standards .cpp != Standards::CPP11)
247247 continue ;
248248
@@ -256,13 +256,11 @@ void CheckClass::checkExplicitConstructors()
256256 if (!func->isConstructor () || func->isDelete () || (!func->hasBody () && func->access == Private))
257257 continue ;
258258
259- if (!func->isExplicit () && func->argCount () == 1 ) {
260- // We must decide, if it is not a copy/move constructor, or it is a copy/move constructor of abstract class.
261- if (func->type != Function::eCopyConstructor && func->type != Function::eMoveConstructor) {
262- noExplicitConstructorError (func->tokenDef , scope->className , scope->type == Scope::eStruct);
263- } else if (isAbstractClass) {
264- noExplicitCopyMoveConstructorError (func->tokenDef , scope->className , scope->type == Scope::eStruct);
265- }
259+ if (!func->isExplicit () &&
260+ func->argCount () == 1 &&
261+ func->type != Function::eCopyConstructor &&
262+ func->type != Function::eMoveConstructor) {
263+ noExplicitConstructorError (func->tokenDef , scope->className , scope->type == Scope::eStruct);
266264 }
267265 }
268266 }
@@ -788,13 +786,6 @@ void CheckClass::noExplicitConstructorError(const Token *tok, const std::string
788786 reportError (tok, Severity::style, " noExplicitConstructor" , message + " \n " + verbose);
789787}
790788
791- void CheckClass::noExplicitCopyMoveConstructorError (const Token *tok, const std::string &classname, bool isStruct)
792- {
793- const std::string message (std::string (isStruct ? " Abstract struct" : " Abstract class" ) + " '" + classname + " ' has a copy/move constructor that is not explicit." );
794- const std::string verbose (message + " For abstract classes, even copy/move constructors may be declared explicit, as, by definition, abstract classes cannot be instantiated, and so objects of such type should never be passed by value." );
795- reportError (tok, Severity::style, " noExplicitCopyMoveConstructor" , message + " \n " + verbose);
796- }
797-
798789void CheckClass::uninitVarError (const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive)
799790{
800791 reportError (tok, Severity::warning, " uninitMemberVar" , " Member variable '" + classname + " ::" + varname + " ' is not initialized in the constructor." , 0U , inconclusive);
0 commit comments