diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8ba563677..fb75b1eb4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5602,6 +5602,10 @@ Token * Tokenizer::initVar(Token * tok) if (tok->str() == "*") tok = tok->next(); + // sizeof is not a variable name.. + if (tok->str() == "sizeof") + return tok; + // check initializer.. if (tok->tokAt(2)->isStandardType() || tok->tokAt(2)->str() == "void") return tok; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3980d2c9a..7437fa7c7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -49,6 +49,7 @@ private: TEST_CASE(tokenize8); TEST_CASE(tokenize9); TEST_CASE(tokenize10); + TEST_CASE(tokenize11); // array access. replace "*(p+1)" => "p[1]" TEST_CASE(tokenize6); @@ -423,6 +424,11 @@ private: ASSERT_EQUALS("__published:", tokenizeAndStringify("__published:", false)); } + void tokenize11() + { + ASSERT_EQUALS("X * sizeof ( Y ( ) ) ;", tokenizeAndStringify("X * sizeof(Y());", false)); + } + void wrong_syntax() { {