fix #2620 reference of typedef of array not simplified properly

This commit is contained in:
Robert Reif 2011-03-03 07:27:53 -05:00
parent 4b0edccec4
commit ee4b4f62d8
2 changed files with 17 additions and 0 deletions

View File

@ -1790,6 +1790,11 @@ void Tokenizer::simplifyTypedef()
{
if (!inCast && !inSizeof)
tok2 = tok2->next();
// skip over reference
if (tok2->str() == "&")
tok2 = tok2->next();
tok2 = copyTokens(tok2, arrayStart, arrayEnd);
tok2 = tok2->next();

View File

@ -243,6 +243,7 @@ private:
TEST_CASE(simplifyTypedef80); // ticket #2587
TEST_CASE(simplifyTypedef81); // ticket #2603
TEST_CASE(simplifyTypedef82); // ticket #2403
TEST_CASE(simplifyTypedef83); // ticket #2620
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4961,6 +4962,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef83() // ticket #2620
{
const char code[] = "typedef char Str[10];\n"
"void f(Str &cl) { }\n";
// The expected result..
const std::string expected("; "
"void f ( char & cl [ 10 ] ) { }");
ASSERT_EQUALS(expected, sizeof_(code));
}
void simplifyTypedefFunction1()
{
{