This commit is contained in:
parent
512b9f512c
commit
e6d285d3ca
|
@ -1500,6 +1500,9 @@ void Tokenizer::simplifyTypedef()
|
|||
if (!inCast && !inSizeof)
|
||||
tok2 = tok2->next();
|
||||
|
||||
if (tok2->str() == "const")
|
||||
tok2 = tok2->next();
|
||||
|
||||
// reference to array?
|
||||
if (tok2->str() == "&") {
|
||||
tok2 = tok2->previous();
|
||||
|
@ -1522,6 +1525,10 @@ void Tokenizer::simplifyTypedef()
|
|||
if (!tok2->next())
|
||||
syntaxError(tok2); // can't recover so quit
|
||||
|
||||
// skip over array dimensions
|
||||
while (tok2->next()->str() == "[")
|
||||
tok2 = tok2->linkAt(1);
|
||||
|
||||
tok2 = TokenList::copyTokens(tok2, arrayStart, arrayEnd);
|
||||
if (!tok2->next())
|
||||
syntaxError(tok2);
|
||||
|
|
|
@ -157,6 +157,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef117); // ticket #6507
|
||||
TEST_CASE(simplifyTypedef118); // ticket #5749
|
||||
TEST_CASE(simplifyTypedef119); // ticket #7541
|
||||
TEST_CASE(simplifyTypedef120); // ticket #8357
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -2443,6 +2444,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef120() { // #8357
|
||||
const char code[] = "typedef char test_utf8_char[5];\n"
|
||||
"static test_utf8_char const bad_chars[] = { };\n"
|
||||
"static void report_good(bool passed, test_utf8_char const c) { };";
|
||||
const char exp [] = "static const char bad_chars [ ] [ 5 ] = { } ; "
|
||||
"static void report_good ( bool passed , const char c [ 5 ] ) { } ;";
|
||||
ASSERT_EQUALS(exp, tok(code, false));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue