Skip to content

Commit 1a52e3b

Browse files
Fix #13329 FP invalidLifetime, shadowArgument in constructor (danmar#7027)
1 parent 9304746 commit 1a52e3b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5017,7 +5017,8 @@ static const Token* skipPointers(const Token* tok)
50175017
tok = tok->tokAt(2);
50185018
}
50195019

5020-
if (Token::simpleMatch(tok, "( *") && Token::simpleMatch(tok->link()->previous(), "] ) ;")) {
5020+
if (Token::simpleMatch(tok, "( *") && Token::simpleMatch(tok->link()->previous(), "] ) ;") &&
5021+
(tok->tokAt(-1)->isStandardType() || tok->tokAt(-1)->isKeyword() || tok->strAt(-1) == "*")) {
50215022
const Token *tok2 = skipPointers(tok->next());
50225023
if (Token::Match(tok2, "%name% [") && Token::simpleMatch(tok2->linkAt(1), "] ) ;"))
50235024
return tok2;

test/testsymboldatabase.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class TestSymbolDatabase : public TestFixture {
424424
TEST_CASE(symboldatabase104);
425425
TEST_CASE(symboldatabase105);
426426
TEST_CASE(symboldatabase106);
427+
TEST_CASE(symboldatabase107);
427428

428429
TEST_CASE(createSymbolDatabaseFindAllScopes1);
429430
TEST_CASE(createSymbolDatabaseFindAllScopes2);
@@ -5656,6 +5657,22 @@ class TestSymbolDatabase : public TestFixture {
56565657
}
56575658
}
56585659

5660+
void symboldatabase107() {
5661+
{
5662+
GET_SYMBOL_DB_DBG("void g(int);\n" // #13329
5663+
"void f(int** pp) {\n"
5664+
" for (int i = 0; i < 2; i++) {\n"
5665+
" g(*pp[i]);\n"
5666+
" }\n"
5667+
"}\n");
5668+
ASSERT(db != nullptr);
5669+
ASSERT_EQUALS("", errout_str());
5670+
ASSERT_EQUALS(3, db->scopeList.size());
5671+
ASSERT_EQUALS(Scope::ScopeType::eFor, db->scopeList.back().type);
5672+
ASSERT_EQUALS(1, db->scopeList.back().varlist.size());
5673+
}
5674+
}
5675+
56595676
void createSymbolDatabaseFindAllScopes1() {
56605677
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
56615678
ASSERT(db->scopeList.size() == 3);

0 commit comments

Comments
 (0)