diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 218e45195..e3e5e042c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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("("); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 4f8e9a94a..dc276be63 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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() { {