Skip to content

Commit 97326fc

Browse files
committed
Fixed danmar#6992 (argument name of function typedef conflicts with local variable name)
1 parent 141dd78 commit 97326fc

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/tokenize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5189,9 +5189,11 @@ void Tokenizer::simplifyFunctionPointers()
51895189
continue;
51905190
while (Token::Match(tok2, "(|:: %type%"))
51915191
tok2 = tok2->tokAt(2);
5192-
if (!Token::Match(tok2, "(|:: * %name%"))
5192+
if (!Token::Match(tok2, "(|:: * *| %name%"))
51935193
continue;
51945194
tok2 = tok2->tokAt(2);
5195+
if (tok2->str() == "*")
5196+
tok2 = tok2->next();
51955197
while (Token::Match(tok2, "%type%|:: %type%|::"))
51965198
tok2 = tok2->next();
51975199

test/testsimplifytypedef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class TestSimplifyTypedef : public TestFixture {
10001000
"class X { } ; "
10011001
"int main ( ) "
10021002
"{ "
1003-
"X ( * * Foo ) ( const X & ) ; Foo = new X ( * ) ( const X & ) [ 2 ] ; "
1003+
"X * * Foo ; Foo = new X ( * ) ( const X & ) [ 2 ] ; "
10041004
"}";
10051005

10061006
ASSERT_EQUALS(expected, tok(code, false));
@@ -2990,8 +2990,8 @@ class TestSimplifyTypedef : public TestFixture {
29902990
"{ "
29912991
"int Format_T2 ; "
29922992
"} "
2993-
"int ( * * t1 ) ( ) ; "
2994-
"int ( * * t2 ) ( ) ;",
2993+
"int * * t1 ; "
2994+
"int * * t2 ;",
29952995
tok(code,false));
29962996
}
29972997

0 commit comments

Comments
 (0)