Skip to content

Commit

Permalink
Fix #13182 FP AssignmentIntegerToAddress with functional-style cast (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Oct 6, 2024
1 parent e8f6d1f commit 5f0cbf0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit 5f0cbf0

Please sign in to comment.