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,
4351
4351
4352
4352
while (Token::Match (tok->next (), " )| . %name% !!(" )) {
4353
4353
// 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 () &&
4355
4355
TokenList::isFunctionHead (tok->linkAt (1 ), " {|;" )) {
4356
4356
tok = tok->tokAt (3 );
4357
4357
continue ;
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class TestVarID : public TestFixture {
46
46
TEST_CASE (varid7);
47
47
TEST_CASE (varidReturn1);
48
48
TEST_CASE (varidReturn2);
49
+ TEST_CASE (varidReturn3);
49
50
TEST_CASE (varid8);
50
51
TEST_CASE (varid9);
51
52
TEST_CASE (varid10);
@@ -517,6 +518,21 @@ class TestVarID : public TestFixture {
517
518
ASSERT_EQUALS (expected, actual);
518
519
}
519
520
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
+
520
536
void varid8 () {
521
537
const std::string actual = tokenize (
522
538
" void func()\n "
You can’t perform that action at this time.
0 commit comments