Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test/testconstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,18 @@ class TestConstructors : public TestFixture {
" { }\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
Expand Down Expand Up @@ -3585,6 +3597,35 @@ class TestConstructors : public TestFixture {
" 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<int, int>* pMap = nullptr;\n"
" std::string* pStr = nullptr;\n"
"};\n");
ASSERT_EQUALS("", errout.str());

check("template <typename U>\n"
"class C1 {}; \n"
"template <typename U, typename V>\n"
"class C2 {};\n"
"namespace A {\n"
" template <typename U>\n"
" class D1 {};\n"
" template <typename U, typename V>\n"
" class D2 {};\n"
"}\n"
"class Test {\n"
"public:\n"
" Test() {}\n"
" C1<int>* c1 = nullptr;\n"
" C2<int, int >* c2 = nullptr;\n"
" A::D1<int>* d1 = nullptr;\n"
" A::D2<int, int >* d2 = nullptr;\n"
" std::map<int, int>* pMap = nullptr;\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}

void uninitConstVar() {
Expand Down