Fixed #5953 (debug: varid0: Function::addArguments) (#1567)

This commit is contained in:
IOBYTE 2019-01-05 13:42:04 -05:00 committed by Daniel Marjamäki
parent 36ffa91825
commit 817c748e4d
2 changed files with 10 additions and 2 deletions

View File

@ -1523,8 +1523,8 @@ void Tokenizer::simplifyTypedef()
if (tok2->str() == "const")
tok2 = tok2->next();
// reference to array?
if (tok2->str() == "&") {
// reference or pointer to array?
if (tok2->str() == "&" || tok2->str() == "*") {
tok2 = tok2->previous();
tok2->insertToken("(");
Token *tok3 = tok2->next();

View File

@ -163,6 +163,7 @@ private:
TEST_CASE(simplifyTypedef123); // ticket #7406
TEST_CASE(simplifyTypedef124); // ticket #7792
TEST_CASE(simplifyTypedef125); // #8749 - typedef char A[10]; p = new A[1];
TEST_CASE(simplifyTypedef126); // ticket #5953
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -2532,6 +2533,13 @@ private:
ASSERT_EQUALS(exp, tok(code, false));
}
void simplifyTypedef126() { // #5953
const char code[] = "typedef char automap_data_t[100];\n"
"void write_array(automap_data_t *data) {}";
const char exp [] = "void write_array ( char ( * data ) [ 100 ] ) { }";
ASSERT_EQUALS(exp, tok(code, false));
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"