You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 68d66bc
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: test/testconstructors.cpp
+80Lines changed: 80 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,14 @@ class TestConstructors : public TestFixture {
232
232
TEST_CASE(uninitTemplate1); // ticket #7372
233
233
234
234
TEST_CASE(unknownTemplateType);
235
+
236
+
TEST_CASE(inheritedCtor1);
237
+
TEST_CASE(inheritedCtor2);
238
+
TEST_CASE(inheritedCtor3);
239
+
TEST_CASE(inheritedCtor4);
240
+
TEST_CASE(inheritedCtor5);
241
+
TEST_CASE(inheritedCtor6);
242
+
TEST_CASE(inheritedCtor7);
235
243
}
236
244
237
245
@@ -4648,6 +4656,78 @@ class TestConstructors : public TestFixture {
4648
4656
ASSERT_EQUALS("", errout_str());
4649
4657
}
4650
4658
4659
+
voidinheritedCtor1() {
4660
+
check("struct Base { Base(int); };\n"
4661
+
"struct Derived : Base {\n"
4662
+
" using Base::Base;\n"
4663
+
" int x;\n"
4664
+
"};\n");
4665
+
ASSERT_EQUALS("[test.cpp:3:17]: (warning) Member variable 'Derived::x' is not initialized in the constructor inherited from 'Base'. [uninitMemberVar]\n", errout_str());
4666
+
}
4667
+
4668
+
voidinheritedCtor2() {
4669
+
check("struct Base { Base(int); };\n"
4670
+
"struct Derived : Base {\n"
4671
+
" using Base::Base;\n"
4672
+
" int x = 0;\n"
4673
+
" int y{};\n"
4674
+
"};\n");
4675
+
ASSERT_EQUALS("", errout_str());
4676
+
}
4677
+
4678
+
voidinheritedCtor3() {
4679
+
check("struct Base { Base(int); };\n"
4680
+
"struct S { S(); int i; };\n"
4681
+
"struct Derived : Base {\n"
4682
+
" using Base::Base;\n"
4683
+
" S s;\n"
4684
+
"};\n");
4685
+
ASSERT_EQUALS("", errout_str());
4686
+
}
4687
+
4688
+
voidinheritedCtor4() {
4689
+
check("struct Base { Base(int); };\n"
4690
+
"struct Derived : Base {\n"
4691
+
" using Base::Base;\n"
4692
+
" int x = 0;\n"
4693
+
" int y;\n"
4694
+
"};\n");
4695
+
ASSERT_EQUALS("[test.cpp:3:17]: (warning) Member variable 'Derived::y' is not initialized in the constructor inherited from 'Base'. [uninitMemberVar]\n", errout_str());
4696
+
}
4697
+
4698
+
voidinheritedCtor5() {
4699
+
check("struct Base { Base(int); };\n"
4700
+
"struct Derived : Base {\n"
4701
+
" using Base::Base;\n"
4702
+
" Derived() : x(0) {}\n"
4703
+
" int x;\n"
4704
+
"};\n");
4705
+
ASSERT_EQUALS("[test.cpp:3:17]: (warning) Member variable 'Derived::x' is not initialized in the constructor inherited from 'Base'. [uninitMemberVar]\n", errout_str());
4706
+
}
4707
+
4708
+
voidinheritedCtor6() {
4709
+
check("struct A { A(int); };\n"
4710
+
"struct B { B(double); };\n"
4711
+
"struct D : A, B {\n"
4712
+
" using A::A;\n"
4713
+
" using B::B;\n"
4714
+
" int x;\n"
4715
+
"};\n");
4716
+
ASSERT_EQUALS("[test.cpp:4:14]: (warning) Member variable 'D::x' is not initialized in the constructor inherited from 'A'. [uninitMemberVar]\n"
4717
+
"[test.cpp:5:14]: (warning) Member variable 'D::x' is not initialized in the constructor inherited from 'B'. [uninitMemberVar]\n",
4718
+
errout_str());
4719
+
}
4720
+
4721
+
voidinheritedCtor7() {
4722
+
check("struct Base { void f(); };\n"
4723
+
"struct Derived : Base {\n"
4724
+
" using Base::f;\n"
4725
+
" int x = 0;\n"
4726
+
" int y;\n"
4727
+
"};\n");
4728
+
ASSERT_EQUALS("[test.cpp:5:9]: (warning) Member variable 'Derived::y' has no initializer. [uninitMemberVarNoCtor]\n", errout_str());
0 commit comments