Fixed #2015 (### Internal error in Cppcheck. Please report it.)

This commit is contained in:
Daniel Marjamäki 2010-09-04 11:49:56 +02:00
parent 9415423352
commit 75fb99cee7
2 changed files with 10 additions and 0 deletions

View File

@ -5602,6 +5602,10 @@ Token * Tokenizer::initVar(Token * tok)
if (tok->str() == "*") if (tok->str() == "*")
tok = tok->next(); tok = tok->next();
// sizeof is not a variable name..
if (tok->str() == "sizeof")
return tok;
// check initializer.. // check initializer..
if (tok->tokAt(2)->isStandardType() || tok->tokAt(2)->str() == "void") if (tok->tokAt(2)->isStandardType() || tok->tokAt(2)->str() == "void")
return tok; return tok;

View File

@ -49,6 +49,7 @@ private:
TEST_CASE(tokenize8); TEST_CASE(tokenize8);
TEST_CASE(tokenize9); TEST_CASE(tokenize9);
TEST_CASE(tokenize10); TEST_CASE(tokenize10);
TEST_CASE(tokenize11);
// array access. replace "*(p+1)" => "p[1]" // array access. replace "*(p+1)" => "p[1]"
TEST_CASE(tokenize6); TEST_CASE(tokenize6);
@ -423,6 +424,11 @@ private:
ASSERT_EQUALS("__published:", tokenizeAndStringify("__published:", false)); ASSERT_EQUALS("__published:", tokenizeAndStringify("__published:", false));
} }
void tokenize11()
{
ASSERT_EQUALS("X * sizeof ( Y ( ) ) ;", tokenizeAndStringify("X * sizeof(Y());", false));
}
void wrong_syntax() void wrong_syntax()
{ {
{ {