Fixed #4682 (using 'struct' disables checking)
This commit is contained in:
parent
945319d804
commit
3f57b5a6ca
|
@ -72,8 +72,23 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
|
|
||||||
// make sure we have valid code
|
// make sure we have valid code
|
||||||
if (!tok2 || !Token::Match(tok2, "{|:"))
|
if (!tok2 || !Token::Match(tok2, "{|:")) {
|
||||||
break;
|
// check for qualified variable
|
||||||
|
if (tok2 && tok2->next()) {
|
||||||
|
if (tok2->next()->str() == ";")
|
||||||
|
tok = tok2->next();
|
||||||
|
else if (Token::Match(tok2->next(), "= {") &&
|
||||||
|
tok2->linkAt(2)->next()->str() == ";")
|
||||||
|
tok = tok2->linkAt(2)->next();
|
||||||
|
else if (Token::Match(tok2->next(), "(|{") &&
|
||||||
|
tok2->next()->link()->next()->str() == ";")
|
||||||
|
tok = tok2->next()->link()->next();
|
||||||
|
else
|
||||||
|
break; // bail
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break; // bail
|
||||||
|
}
|
||||||
|
|
||||||
Scope *new_scope = findScope(tok->next(), scope);
|
Scope *new_scope = findScope(tok->next(), scope);
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ private:
|
||||||
TEST_CASE(symboldatabase29); // ticket #4442 (segmentation fault)
|
TEST_CASE(symboldatabase29); // ticket #4442 (segmentation fault)
|
||||||
TEST_CASE(symboldatabase30);
|
TEST_CASE(symboldatabase30);
|
||||||
TEST_CASE(symboldatabase31);
|
TEST_CASE(symboldatabase31);
|
||||||
|
TEST_CASE(symboldatabase33); // ticket #4682 (false negatives)
|
||||||
|
|
||||||
TEST_CASE(isImplicitlyVirtual);
|
TEST_CASE(isImplicitlyVirtual);
|
||||||
|
|
||||||
|
@ -1445,6 +1446,16 @@ private:
|
||||||
ASSERT(db && db->findScopeByName("Deri") && db->findScopeByName("Deri")->definedType->getFunction("foo"));
|
ASSERT(db && db->findScopeByName("Deri") && db->findScopeByName("Deri")->definedType->getFunction("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void symboldatabase33() { // ticket #4682
|
||||||
|
GET_SYMBOL_DB("static struct A::B s;\n"
|
||||||
|
"static struct A::B t = { 0 };\n"
|
||||||
|
"static struct A::B u(0);\n"
|
||||||
|
"static struct A::B v{0};\n"
|
||||||
|
"static struct A::B w({0});\n"
|
||||||
|
"void foo() { }");
|
||||||
|
ASSERT(db && db->functionScopes.size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
void isImplicitlyVirtual() {
|
void isImplicitlyVirtual() {
|
||||||
{
|
{
|
||||||
GET_SYMBOL_DB("class Base {\n"
|
GET_SYMBOL_DB("class Base {\n"
|
||||||
|
|
Loading…
Reference in New Issue