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
@@ -1609,6 +1610,15 @@ class TestConstructors : public TestFixture {
1609
1610
ASSERT_EQUALS("", errout_str());
1610
1611
}
1611
1612
}
1613
+
voidinitvar_derived_private_constructor() {
1614
+
check("class B { int i; };\n"
1615
+
"class D : B {\n"
1616
+
" explicit D(int) {}\n"
1617
+
"};\n");
1618
+
ASSERT_EQUALS("[test.cpp:1:1]: (style) The class 'B' does not declare a constructor although it has private member variables which likely require initialization. [noConstructor]\n"
1619
+
"[test.cpp:3:14]: (warning) Member variable 'B::i' is not initialized in the constructor. Maybe it should be initialized directly in the class B? [uninitDerivedMemberVarPrivate]\n",
Copy file name to clipboardExpand all lines: test/testother.cpp
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -255,6 +255,8 @@ class TestOther : public TestFixture {
255
255
TEST_CASE(raceAfterInterlockedDecrement);
256
256
257
257
TEST_CASE(testUnusedLabel);
258
+
TEST_CASE(testUnusedLabelConfiguration);
259
+
TEST_CASE(testUnusedLabelSwitchConfiguration);
258
260
259
261
TEST_CASE(testEvaluationOrder);
260
262
TEST_CASE(testEvaluationOrderSelfAssignment);
@@ -11793,6 +11795,36 @@ class TestOther : public TestFixture {
11793
11795
ASSERT_EQUALS("[test.cpp:6:5]: (style) Label 'label' is not used. [unusedLabel]\n", errout_str());
11794
11796
}
11795
11797
11798
+
11799
+
void testUnusedLabelConfiguration() {
11800
+
checkP("void f() {\n"
11801
+
"#ifdef X\n"
11802
+
" goto END;\n"
11803
+
"#endif\n"
11804
+
"END:\n"
11805
+
"}");
11806
+
ASSERT_EQUALS("[test.cpp:5:1]: (style) Label 'END' is not used. There is #if in function body so the label might be used in code that is removed by the preprocessor. [unusedLabelConfiguration]\n",
11807
+
errout_str());
11808
+
}
11809
+
11810
+
void testUnusedLabelSwitchConfiguration() {
11811
+
checkP("void f(int i) {\n"
11812
+
" switch (i) {\n"
11813
+
" default:\n"
11814
+
" break;\n"
11815
+
"#ifdef X\n"
11816
+
" case 1:\n"
11817
+
" goto END;\n"
11818
+
"#endif\n"
11819
+
" case 2:\n"
11820
+
" END:\n"
11821
+
" return;\n"
11822
+
" }\n"
11823
+
"}");
11824
+
ASSERT_EQUALS("[test.cpp:10:5]: (warning) Label 'END' is not used. There is #if in function body so the label might be used in code that is removed by the preprocessor. Should this be a 'case' of the enclosing switch()? [unusedLabelSwitchConfiguration]\n",
0 commit comments