Make single-argument test constructors explicit

This commit is contained in:
Richard Quirk 2011-10-28 22:06:57 +02:00
parent d75ef01d2b
commit b88d61dcb4
2 changed files with 21 additions and 21 deletions

View File

@ -1683,7 +1683,7 @@ private:
" FILE *fp;\n" " FILE *fp;\n"
"\n" "\n"
"public:\n" "public:\n"
" C(FILE *fp);\n" " explicit C(FILE *fp);\n"
"};\n" "};\n"
"\n" "\n"
"C::C(FILE *fp) {\n" "C::C(FILE *fp) {\n"
@ -1761,7 +1761,7 @@ private:
checkUninitVar("class Foo : public Bar\n" checkUninitVar("class Foo : public Bar\n"
"{\n" "{\n"
"public:\n" "public:\n"
" Foo(int i) : Bar(mi=i) { }\n" " explicit Foo(int i) : Bar(mi=i) { }\n"
"private:\n" "private:\n"
" int mi;\n" " int mi;\n"
"};\n"); "};\n");
@ -1811,7 +1811,7 @@ private:
"private:\n" "private:\n"
" int xasd;\n" " int xasd;\n"
"public:\n" "public:\n"
" Prefs(wxSize size);\n" " explicit Prefs(wxSize size);\n"
"};\n" "};\n"
"Prefs::Prefs(wxSize size)\n" "Prefs::Prefs(wxSize size)\n"
"{\n" "{\n"
@ -1835,7 +1835,7 @@ private:
void uninitVar11() { void uninitVar11() {
checkUninitVar("class A {\n" checkUninitVar("class A {\n"
"public:\n" "public:\n"
" A(int a = 0);\n" " explicit A(int a = 0);\n"
"private:\n" "private:\n"
" int var;\n" " int var;\n"
"};\n" "};\n"
@ -2138,7 +2138,7 @@ private:
void uninitVar18() { // ticket #2465 void uninitVar18() { // ticket #2465
checkUninitVar("struct Altren\n" checkUninitVar("struct Altren\n"
"{\n" "{\n"
" Altren(int _a = 0) : value(0) { }\n" " explicit Altren(int _a = 0) : value(0) { }\n"
" int value;\n" " int value;\n"
"};\n" "};\n"
"class A\n" "class A\n"
@ -2152,7 +2152,7 @@ private:
checkUninitVar("struct Altren\n" checkUninitVar("struct Altren\n"
"{\n" "{\n"
" Altren(int _a) : value(0) { }\n" " explicit Altren(int _a) : value(0) { }\n"
" int value;\n" " int value;\n"
"};\n" "};\n"
"class A\n" "class A\n"
@ -2171,7 +2171,7 @@ private:
" char* m_str;\n" " char* m_str;\n"
" int m_len;\n" " int m_len;\n"
"public:\n" "public:\n"
" mystring(const char* str)\n" " explicit mystring(const char* str)\n"
" {\n" " {\n"
" m_len = strlen(str);\n" " m_len = strlen(str);\n"
" m_str = (char*) malloc(m_len+1);\n" " m_str = (char*) malloc(m_len+1);\n"
@ -2602,7 +2602,7 @@ private:
"private:\n" "private:\n"
" int foo;\n" " int foo;\n"
"public:\n" "public:\n"
" Foo(std::istream &in)\n" " explicit Foo(std::istream &in)\n"
" {\n" " {\n"
" if(!(in >> foo))\n" " if(!(in >> foo))\n"
" throw 0;\n" " throw 0;\n"
@ -2659,7 +2659,7 @@ private:
" int foo;\n" " int foo;\n"
" Foo() { }\n" " Foo() { }\n"
"public:\n" "public:\n"
" Foo(int _i) { }\n" " explicit Foo(int _i) { }\n"
"};\n"); "};\n");
ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Foo::foo' is not initialized in the constructor.\n", errout.str()); ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'Foo::foo' is not initialized in the constructor.\n", errout.str());

View File

@ -227,7 +227,7 @@ private:
"{\n" "{\n"
"public:\n" "public:\n"
" Fred();\n" " Fred();\n"
" Fred(int _i);\n" " explicit Fred(int _i);\n"
" int i;\n" " int i;\n"
"};\n" "};\n"
"Fred::Fred()\n" "Fred::Fred()\n"
@ -241,7 +241,7 @@ private:
check("struct Fred\n" check("struct Fred\n"
"{\n" "{\n"
" Fred();\n" " Fred();\n"
" Fred(int _i);\n" " explicit Fred(int _i);\n"
" int i;\n" " int i;\n"
"};\n" "};\n"
"Fred::Fred()\n" "Fred::Fred()\n"
@ -647,7 +647,7 @@ private:
check("class c\n" check("class c\n"
"{\n" "{\n"
" c();\n" " c();\n"
" c(bool b);" " explicit c(bool b);"
"\n" "\n"
" void InitInt();\n" " void InitInt();\n"
"\n" "\n"
@ -677,7 +677,7 @@ private:
check("struct c\n" check("struct c\n"
"{\n" "{\n"
" c();\n" " c();\n"
" c(bool b);" " explicit c(bool b);"
"\n" "\n"
" void InitInt();\n" " void InitInt();\n"
"\n" "\n"
@ -850,12 +850,12 @@ private:
"public:\n" "public:\n"
" A();\n" " A();\n"
" struct B {\n" " struct B {\n"
" B(int x);\n" " explicit B(int x);\n"
" struct C {\n" " struct C {\n"
" C(int y);\n" " explicit C(int y);\n"
" struct D {\n" " struct D {\n"
" int d;\n" " int d;\n"
" D(int z);\n" " explicit D(int z);\n"
" };\n" " };\n"
" int c;\n" " int c;\n"
" };\n" " };\n"
@ -879,9 +879,9 @@ private:
"public:\n" "public:\n"
" A();\n" " A();\n"
" struct B {\n" " struct B {\n"
" B(int x);\n" " explicit B(int x);\n"
" struct C {\n" " struct C {\n"
" C(int y);\n" " explicit C(int y);\n"
" struct D {\n" " struct D {\n"
" D(const D &);\n" " D(const D &);\n"
" int d;\n" " int d;\n"
@ -908,13 +908,13 @@ private:
"public:\n" "public:\n"
" A();\n" " A();\n"
" struct B {\n" " struct B {\n"
" B(int x);\n" " explicit B(int x);\n"
" struct C {\n" " struct C {\n"
" C(int y);\n" " explicit C(int y);\n"
" struct D {\n" " struct D {\n"
" struct E { int e; };\n" " struct E { int e; };\n"
" struct E d;\n" " struct E d;\n"
" D(const E &);\n" " explicit D(const E &);\n"
" };\n" " };\n"
" int c;\n" " int c;\n"
" };\n" " };\n"