diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 3a47e03d5..1c2925f3e 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -2263,7 +2263,7 @@ bool Tokenizer::simplifyVarDecl() Token *tok2 = type0; unsigned int typelen = 1; - while (Token::Match(tok2, "%type% %type% *| %var%")) + while (Token::Match(tok2, "%type% %type% *| *| %var%")) { if (tok2->str() == "const") isconst = true; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 502c30863..e0983421c 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1031,6 +1031,22 @@ private: ASSERT_EQUALS(" void foo ( ) { char * a ; char * b ; delete a ; delete b ; }", sizeof_(code)); } + { + const char code[] = "void foo()\n" + "{\n" + " struct A *a, *b;\n" + "}\n"; + ASSERT_EQUALS(" void foo ( ) { struct A * a ; struct A * b ; }", sizeof_(code)); + } + + { + const char code[] = "void foo()\n" + "{\n" + " struct A **a, **b;\n" + "}\n"; + ASSERT_EQUALS(" void foo ( ) { struct A * * a ; struct A * * b ; }", sizeof_(code)); + } + { const char code[] = "void foo()\n" "{\n"