diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index c1a7a0b2b..d2a38da7c 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -3533,6 +3533,18 @@ private: " { }\n" "};"); ASSERT_EQUALS("[test.cpp:7]: (warning) Member variable 'A::i' is not initialized in the constructor.\n", errout.str()); + + check("class bar {\n" // #9887 + " int length;\n" + " bar() { length = 0; }\n" + "};\n" + "class foo {\n" + " int x;\n" + " foo() { Set(bar()); }\n" + " void Set(int num) { x = 1; }\n" + " void Set(bar num) { x = num.length; }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void uninitVarOperatorEqual() { // ticket #2415 @@ -3596,6 +3608,35 @@ private: " B() { }\n" "};"); ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'B::a' is not initialized in the constructor.\n", errout.str()); + + check("class Test {\n" // #8498 + "public:\n" + " Test() {}\n" + " std::map* pMap = nullptr;\n" + " std::string* pStr = nullptr;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + + check("template \n" + "class C1 {}; \n" + "template \n" + "class C2 {};\n" + "namespace A {\n" + " template \n" + " class D1 {};\n" + " template \n" + " class D2 {};\n" + "}\n" + "class Test {\n" + "public:\n" + " Test() {}\n" + " C1* c1 = nullptr;\n" + " C2* c2 = nullptr;\n" + " A::D1* d1 = nullptr;\n" + " A::D2* d2 = nullptr;\n" + " std::map* pMap = nullptr;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void uninitConstVar() {