Fixed #954 (Tokenizer: correctly simplify sizeof of class members)
http://sourceforge.net/apps/trac/cppcheck/ticket/954
This commit is contained in:
parent
6384b83938
commit
2ec5438186
|
@ -1721,6 +1721,11 @@ void Tokenizer::simplifySizeof()
|
|||
// nothing after this
|
||||
tempToken = tempToken->tokAt(2);
|
||||
}
|
||||
else if (Token::simpleMatch(tempToken->next(), ") ."))
|
||||
{
|
||||
tempToken = tempToken->tokAt(2);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ok, we should be clean. Add ) after tempToken
|
||||
tok->insertToken("(");
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
TEST_CASE(sizeof11);
|
||||
TEST_CASE(sizeof12);
|
||||
TEST_CASE(sizeof13);
|
||||
TEST_CASE(sizeof14);
|
||||
TEST_CASE(casting);
|
||||
|
||||
TEST_CASE(strlen1);
|
||||
|
@ -884,6 +885,22 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void sizeof14()
|
||||
{
|
||||
// ticket #954
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" A **a;\n"
|
||||
" int aa = sizeof *(*a)->b;\n"
|
||||
"}\n";
|
||||
const char expected[] = "void f ( ) "
|
||||
"{"
|
||||
" A * * a ;"
|
||||
" int aa ; aa = sizeof ( * ( * a ) . b ) ; "
|
||||
"}";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void casting()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue