Skip to content

Commit 817c748

Browse files
IOBYTEdanmar
authored andcommitted
Fixed danmar#5953 (debug: varid0: Function::addArguments) (danmar#1567)
1 parent 36ffa91 commit 817c748

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/tokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,8 +1523,8 @@ void Tokenizer::simplifyTypedef()
15231523
if (tok2->str() == "const")
15241524
tok2 = tok2->next();
15251525

1526-
// reference to array?
1527-
if (tok2->str() == "&") {
1526+
// reference or pointer to array?
1527+
if (tok2->str() == "&" || tok2->str() == "*") {
15281528
tok2 = tok2->previous();
15291529
tok2->insertToken("(");
15301530
Token *tok3 = tok2->next();

test/testsimplifytypedef.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class TestSimplifyTypedef : public TestFixture {
163163
TEST_CASE(simplifyTypedef123); // ticket #7406
164164
TEST_CASE(simplifyTypedef124); // ticket #7792
165165
TEST_CASE(simplifyTypedef125); // #8749 - typedef char A[10]; p = new A[1];
166+
TEST_CASE(simplifyTypedef126); // ticket #5953
166167

167168
TEST_CASE(simplifyTypedefFunction1);
168169
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@@ -2532,6 +2533,13 @@ class TestSimplifyTypedef : public TestFixture {
25322533
ASSERT_EQUALS(exp, tok(code, false));
25332534
}
25342535

2536+
void simplifyTypedef126() { // #5953
2537+
const char code[] = "typedef char automap_data_t[100];\n"
2538+
"void write_array(automap_data_t *data) {}";
2539+
const char exp [] = "void write_array ( char ( * data ) [ 100 ] ) { }";
2540+
ASSERT_EQUALS(exp, tok(code, false));
2541+
}
2542+
25352543
void simplifyTypedefFunction1() {
25362544
{
25372545
const char code[] = "typedef void (*my_func)();\n"

0 commit comments

Comments
 (0)