diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index aa6833f274b..bbcf91c90ce 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5017,7 +5017,8 @@ static const Token* skipPointers(const Token* tok) tok = tok->tokAt(2); } - if (Token::simpleMatch(tok, "( *") && Token::simpleMatch(tok->link()->previous(), "] ) ;")) { + if (Token::simpleMatch(tok, "( *") && Token::simpleMatch(tok->link()->previous(), "] ) ;") && + (tok->tokAt(-1)->isStandardType() || tok->tokAt(-1)->isKeyword() || tok->strAt(-1) == "*")) { const Token *tok2 = skipPointers(tok->next()); if (Token::Match(tok2, "%name% [") && Token::simpleMatch(tok2->linkAt(1), "] ) ;")) return tok2; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 7b433e00a8c..6e933fe383e 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -424,6 +424,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(symboldatabase104); TEST_CASE(symboldatabase105); TEST_CASE(symboldatabase106); + TEST_CASE(symboldatabase107); TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes2); @@ -5656,6 +5657,22 @@ class TestSymbolDatabase : public TestFixture { } } + void symboldatabase107() { + { + GET_SYMBOL_DB_DBG("void g(int);\n" // #13329 + "void f(int** pp) {\n" + " for (int i = 0; i < 2; i++) {\n" + " g(*pp[i]);\n" + " }\n" + "}\n"); + ASSERT(db != nullptr); + ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS(3, db->scopeList.size()); + ASSERT_EQUALS(Scope::ScopeType::eFor, db->scopeList.back().type); + ASSERT_EQUALS(1, db->scopeList.back().varlist.size()); + } + } + void createSymbolDatabaseFindAllScopes1() { GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); ASSERT(db->scopeList.size() == 3);