parent
b2f15fdbb1
commit
1aceded300
|
@ -377,9 +377,10 @@ void CheckClass::checkExplicitConstructors()
|
||||||
|
|
||||||
if (!func.isExplicit() &&
|
if (!func.isExplicit() &&
|
||||||
func.argCount() > 0 && func.minArgCount() < 2 &&
|
func.argCount() > 0 && func.minArgCount() < 2 &&
|
||||||
func.argumentList.front().getTypeName() != "std::initializer_list" &&
|
|
||||||
func.type != Function::eCopyConstructor &&
|
func.type != Function::eCopyConstructor &&
|
||||||
func.type != Function::eMoveConstructor) {
|
func.type != Function::eMoveConstructor &&
|
||||||
|
!(func.templateDef && Token::simpleMatch(func.argumentList.front().typeEndToken(), "...")) &&
|
||||||
|
func.argumentList.front().getTypeName() != "std::initializer_list") {
|
||||||
noExplicitConstructorError(func.tokenDef, scope->className, scope->type == Scope::eStruct);
|
noExplicitConstructorError(func.tokenDef, scope->className, scope->type == Scope::eStruct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,6 +493,22 @@ private:
|
||||||
" std::vector<int> v;\n"
|
" std::vector<int> v;\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkExplicitConstructors("template<class T>\n" // #10977
|
||||||
|
"struct A {\n"
|
||||||
|
" template<class... Ts>\n"
|
||||||
|
" A(Ts&&... ts) {}\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkExplicitConstructors("class Color {\n" // #7176
|
||||||
|
"public:\n"
|
||||||
|
" Color(unsigned int rgba);\n"
|
||||||
|
" Color(std::uint8_t r = 0, std::uint8_t g = 0, std::uint8_t b = 0, std::uint8_t a = 255);\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:3]: (style) Class 'Color' has a constructor with 1 argument that is not explicit.\n"
|
||||||
|
"[test.cpp:4]: (style) Class 'Color' has a constructor with 1 argument that is not explicit.\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkDuplInheritedMembers(code) checkDuplInheritedMembers_(code, __FILE__, __LINE__)
|
#define checkDuplInheritedMembers(code) checkDuplInheritedMembers_(code, __FILE__, __LINE__)
|
||||||
|
|
|
@ -550,6 +550,21 @@ private:
|
||||||
" S s;\n"
|
" S s;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage( // #11109
|
||||||
|
"class D { public: D(); };\n"
|
||||||
|
"class E { public: ~E(); };\n"
|
||||||
|
"class F {\n"
|
||||||
|
"public:\n"
|
||||||
|
" F();\n"
|
||||||
|
" ~F();\n"
|
||||||
|
"};\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" D d;\n"
|
||||||
|
" E e;\n"
|
||||||
|
" F f;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanFunction() {
|
void cleanFunction() {
|
||||||
|
|
Loading…
Reference in New Issue