Tokenizer: fix for multiple array definitions for a single typedef

This commit is contained in:
Robert Reif 2010-01-31 07:16:19 +01:00 committed by Daniel Marjamäki
parent 630d9ba552
commit d17d199415
2 changed files with 13 additions and 2 deletions

View File

@ -579,6 +579,7 @@ void Tokenizer::simplifyTypedef()
else
{
// unhandled typedef, skip it and continue
tok = tok->tokAt(offset);
continue;
}
}
@ -816,6 +817,8 @@ void Tokenizer::simplifyTypedef()
if (tok->tokAt(offset) && tok->tokAt(offset)->str() == "[")
{
arrayStart = tok->tokAt(offset);
bool atEnd = false;
while (!atEnd)
{
@ -831,6 +834,8 @@ void Tokenizer::simplifyTypedef()
else
offset++;
}
arrayEnd = tok->tokAt(offset++);
}
if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), ";|,"))

View File

@ -2976,17 +2976,23 @@ private:
const char code[] = "typedef int array [ice_or<is_int<int>::value, is_int<UDT>::value>::value ? 1 : -1];\n"
"typedef int array1 [N];\n"
"typedef int array2 [N][M];\n"
"typedef int int_t, int_array[N];\n"
"array a;\n"
"array1 a1;\n"
"array2 a2;";
"array2 a2;\n"
"int_t t;\n"
"int_array ia;";
const char expected[] =
"; "
"; "
"; "
"; "
"int a [ ice_or < is_int < int > :: value , is_int < UDT > :: value > :: value ? 1 : - 1 ] ; "
"int a1 [ N ] ; "
"int a2 [ N ] [ M ] ;";
"int a2 [ N ] [ M ] ; "
"int t ; "
"int ia [ N ] ;";
ASSERT_EQUALS(expected, tok(code, false));
}