diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index dde0b7ddf7e..a351ae2092b 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 f24c4455767..88710b7e887 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); @@ -5653,6 +5654,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);