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
@@ -1417,7 +1417,7 @@ class TestConstructors : public TestFixture {
1417
1417
1418
1418
}
1419
1419
1420
-
voidinitvar_derived_pod_struct() {
1420
+
voidinitvar_derived_pod_struct_with_union() {
1421
1421
check("struct S {\n"
1422
1422
" union {\n"
1423
1423
" unsigned short all;\n"
@@ -1433,6 +1433,24 @@ class TestConstructors : public TestFixture {
1433
1433
" C() { all = 0; tick = 0; }\n"
1434
1434
"};");
1435
1435
ASSERT_EQUALS("", errout.str());
1436
+
1437
+
check("struct S {\n"
1438
+
" union {\n"
1439
+
" unsigned short all;\n"
1440
+
" struct {\n"
1441
+
" unsigned char flag1;\n"
1442
+
" unsigned char flag2;\n"
1443
+
" };\n"
1444
+
" };\n"
1445
+
"};\n"
1446
+
"\n"
1447
+
"class C : public S {\n"
1448
+
"public:\n"
1449
+
" C() {}\n"
1450
+
"};");
1451
+
ASSERT_EQUALS("[test.cpp:13]: (warning) Member variable 'S::all' is not initialized in the constructor. Maybe it should be initialized directly in the class S?\n"
1452
+
"[test.cpp:13]: (warning) Member variable 'S::flag1' is not initialized in the constructor. Maybe it should be initialized directly in the class S?\n"
1453
+
"[test.cpp:13]: (warning) Member variable 'S::flag2' is not initialized in the constructor. Maybe it should be initialized directly in the class S?\n", errout.str());
1436
1454
}
1437
1455
1438
1456
voidinitvar_private_constructor() {
@@ -3634,6 +3652,18 @@ class TestConstructors : public TestFixture {
3634
3652
" void Init( Structure& S ) { S.C = 0; };\n"
3635
3653
"};");
3636
3654
ASSERT_EQUALS("", errout.str());
3655
+
3656
+
check("struct Structure {\n"
3657
+
" int C;\n"
3658
+
"};\n"
3659
+
"\n"
3660
+
"class A {\n"
3661
+
" Structure B;\n"
3662
+
"public:\n"
3663
+
" A() { Init( B ); };\n"
3664
+
" void Init(const Structure& S) { }\n"
3665
+
"};");
3666
+
ASSERT_EQUALS("[test.cpp:8]: (warning) Member variable 'A::B' is not initialized in the constructor.\n", errout.str());
0 commit comments