Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ namespace {
tok2 = insertTokens(tok2, mRangeTypeQualifiers);
Token* tok3 = tok2->insertToken(")");
Token::createMutualLinks(tok, tok3);
tok->insertTokenBefore("(");
tok3 = tok3->linkAt(1);
tok3 = tok3->insertToken(")");
Token::createMutualLinks(tok->tokAt(-1), tok3);
}
return;
}
Expand Down
13 changes: 12 additions & 1 deletion test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3387,7 +3387,7 @@ class TestSimplifyTypedef : public TestFixture {
// #11430
const char code3[] = "typedef char* T;\n"
"T f() { return T(\"abc\"); }\n";
ASSERT_EQUALS("char * f ( ) { return ( char * ) ( \"abc\" ) ; }", tok(code3));
ASSERT_EQUALS("char * f ( ) { return ( ( char * ) ( \"abc\" ) ) ; }", tok(code3));

const char code4[] = "typedef struct _a *A;\n" // #13104
"typedef struct _b* B;\n"
Expand All @@ -3399,6 +3399,17 @@ class TestSimplifyTypedef : public TestFixture {
ASSERT_EQUALS("extern struct _a * ( * get ) ( struct _b * ) ; "
"struct _a * f ( ) { return get ( 0 ) ; }",
tok(code4));

const char code5[] = "struct S { int x; };\n" // #13182
"typedef S* PS;\n"
"void f(void* a[], int i) {\n"
" PS(a[i])->x = i;\n"
"}\n";
ASSERT_EQUALS("struct S { int x ; } ; "
"void f ( void * a [ ] , int i ) { "
"( ( S * ) ( a [ i ] ) ) . x = i ; "
"}",
tok(code5));
}

void simplifyTypedef143() { // #11506
Expand Down