File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,6 +233,7 @@ class TestSymbolDatabase : public TestFixture {
233233 TEST_CASE(rangeBasedFor);
234234
235235 TEST_CASE(memberVar1);
236+ TEST_CASE(memberVar2);
236237 TEST_CASE(arrayMemberVar1);
237238 TEST_CASE(arrayMemberVar2);
238239 TEST_CASE(arrayMemberVar3);
@@ -1864,6 +1865,22 @@ class TestSymbolDatabase : public TestFixture {
18641865 ASSERT(Token::simpleMatch(tok->variable()->typeStartToken(), "int x ;"));
18651866 }
18661867
1868+ void memberVar2() {
1869+ GET_SYMBOL_DB( "struct S { void (*fp)(); };\n"
1870+ "void g();\n"
1871+ "void f() {\n"
1872+ " S s;\n"
1873+ " s.fp = g;\n"
1874+ " s.fp();\n"
1875+ "}\n");
1876+
1877+ ASSERT(db != nullptr);
1878+ const Token *fp1 = Token::findsimplematch(tokenizer.tokens(), "fp =");
1879+ const Token *fp2 = Token::findsimplematch(tokenizer.tokens(), "fp (");
1880+ ASSERT(fp1->varId());
1881+ ASSERT_EQUALS(fp2->varId(), fp1->varId());
1882+ }
1883+
18671884 void arrayMemberVar1() {
18681885 GET_SYMBOL_DB("struct Foo {\n"
18691886 " int x;\n"
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ class TestUnusedVar : public TestFixture {
158158 TEST_CASE (localvar71);
159159 TEST_CASE (localvar72);
160160 TEST_CASE (localvar73);
161+ TEST_CASE (localvar74);
161162 TEST_CASE (localvarloops); // loops
162163 TEST_CASE (localvaralias1);
163164 TEST_CASE (localvaralias2); // ticket #1637
@@ -4100,6 +4101,17 @@ class TestUnusedVar : public TestFixture {
41004101 ASSERT_EQUALS (" " , errout_str ());
41014102 }
41024103
4104+ void localvar74 () {
4105+ functionVariableUsage (" struct S { void (*fp)(); };\n "
4106+ " void g();\n "
4107+ " void f() {\n "
4108+ " S s;\n "
4109+ " s.fp = g;\n "
4110+ " s.fp();\n "
4111+ " }\n " );
4112+ ASSERT_EQUALS (" " , errout_str ());
4113+ }
4114+
41034115 void localvarloops () {
41044116 // loops
41054117 functionVariableUsage (" void fun(int c) {\n "
You can’t perform that action at this time.
0 commit comments