File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ class TestUninitVar : public TestFixture {
9797 TEST_CASE (uninitvar_memberfunction);
9898 TEST_CASE (uninitvar_nonmember); // crash in ycmd test
9999 TEST_CASE (uninitvarDesignatedInitializers);
100+ TEST_CASE (uninitvarMemberPointer);
100101
101102 TEST_CASE (isVariableUsageDeref); // *p
102103 TEST_CASE (isVariableUsageDerefValueflow); // *p
@@ -7825,6 +7826,16 @@ class TestUninitVar : public TestFixture {
78257826 ASSERT_EQUALS (" " , errout_str ());
78267827 }
78277828
7829+ void uninitvarMemberPointer () {
7830+ checkUninitVar (" void f()\n "
7831+ " {\n "
7832+ " struct S {};\n "
7833+ " int S::* mp;\n "
7834+ " if (mp) {}\n "
7835+ " }\n " );
7836+ ASSERT_EQUALS (" [test.cpp:5:7]: (error) Uninitialized variable: mp [legacyUninitvar]\n " , errout_str ());
7837+ }
7838+
78287839 void isVariableUsageDeref () {
78297840 // *p
78307841 checkUninitVar (" void f() {\n "
Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ class TestUnusedVar : public TestFixture {
154154 TEST_CASE (localvar69);
155155 TEST_CASE (localvar70);
156156 TEST_CASE (localvar71);
157+ TEST_CASE (localvar72);
157158 TEST_CASE (localvarloops); // loops
158159 TEST_CASE (localvaralias1);
159160 TEST_CASE (localvaralias2); // ticket #1637
@@ -4046,6 +4047,15 @@ class TestUnusedVar : public TestFixture {
40464047 ASSERT_EQUALS (" " , errout_str ());
40474048 }
40484049
4050+ void localvar72 () {
4051+ functionVariableUsage (" void f()\n "
4052+ " {\n "
4053+ " struct S {};\n "
4054+ " int S::* mp;\n "
4055+ " }\n " );
4056+ ASSERT_EQUALS (" [test.cpp:4:12]: (style) Unused variable: mp [unusedVariable]\n " , errout_str ());
4057+ }
4058+
40494059 void localvarloops () {
40504060 // loops
40514061 functionVariableUsage (" void fun(int c) {\n "
You can’t perform that action at this time.
0 commit comments