File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -4351,7 +4351,7 @@ static void setVarIdStructMembers(Token *&tok1,
43514351
43524352 while (Token::Match (tok->next (), " )| . %name% !!(" )) {
43534353 // Don't set varid for trailing return type
4354- if (tok->strAt (1 ) == " )" && Token::Match (tok->linkAt (1 )->tokAt (-1 ), " %name%|]" ) &&
4354+ if (tok->strAt (1 ) == " )" && Token::Match (tok->linkAt (1 )->tokAt (-1 ), " %name%|]" ) && !tok-> linkAt ( 1 )-> tokAt (- 1 )-> isKeyword () &&
43554355 TokenList::isFunctionHead (tok->linkAt (1 ), " {|;" )) {
43564356 tok = tok->tokAt (3 );
43574357 continue ;
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class TestVarID : public TestFixture {
4646 TEST_CASE (varid7);
4747 TEST_CASE (varidReturn1);
4848 TEST_CASE (varidReturn2);
49+ TEST_CASE (varidReturn3);
4950 TEST_CASE (varid8);
5051 TEST_CASE (varid9);
5152 TEST_CASE (varid10);
@@ -517,6 +518,21 @@ class TestVarID : public TestFixture {
517518 ASSERT_EQUALS (expected, actual);
518519 }
519520
521+ void varidReturn3 () {
522+ const std::string actual = tokenize (
523+ " struct S { int i; };\n "
524+ " int f(S s) {\n "
525+ " return (&s)->i;\n "
526+ " }\n " );
527+
528+ const char expected[] = " 1: struct S { int i@1 ; } ;\n "
529+ " 2: int f ( S s@2 ) {\n "
530+ " 3: return ( & s@2 ) . i@3 ;\n "
531+ " 4: }\n " ;
532+
533+ ASSERT_EQUALS (expected, actual);
534+ }
535+
520536 void varid8 () {
521537 const std::string actual = tokenize (
522538 " void func()\n "
You can’t perform that action at this time.
0 commit comments