Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading