Fix FP missingOverride (#4894)
This commit is contained in:
parent
716fcc5e96
commit
3b61ecd973
|
@ -2647,10 +2647,10 @@ static bool typesMatch(
|
||||||
const Token **new_second)
|
const Token **new_second)
|
||||||
{
|
{
|
||||||
// get first type
|
// get first type
|
||||||
const Type * first_type = first_scope->check->findType(first_token, first_scope);
|
const Type* first_type = first_scope->check->findType(first_token, first_scope, /*lookOutside*/ true);
|
||||||
if (first_type) {
|
if (first_type) {
|
||||||
// get second type
|
// get second type
|
||||||
const Type * second_type = second_scope->check->findType(second_token, second_scope);
|
const Type* second_type = second_scope->check->findType(second_token, second_scope, /*lookOutside*/ true);
|
||||||
// check if types match
|
// check if types match
|
||||||
if (first_type == second_type) {
|
if (first_type == second_type) {
|
||||||
const Token* tok1 = first_token;
|
const Token* tok1 = first_token;
|
||||||
|
@ -5840,14 +5840,15 @@ const Type* SymbolDatabase::findType(const Token *startTok, const Scope *startSc
|
||||||
tok = startTok;
|
tok = startTok;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Type * type = scope->findType(tok->str());
|
const Scope* scope1{};
|
||||||
|
const Type* type = scope->findType(tok->str());
|
||||||
if (type)
|
if (type)
|
||||||
return type;
|
return type;
|
||||||
else if (const Scope *scope1 = scope->findRecordInBase(tok->str())) {
|
if (lookOutside && (scope1 = scope->findRecordInBase(tok->str()))) {
|
||||||
type = scope1->definedType;
|
type = scope1->definedType;
|
||||||
if (type)
|
if (type)
|
||||||
return type;
|
return type;
|
||||||
} else if (scope->type == Scope::ScopeType::eNamespace && lookOutside) {
|
} else if (lookOutside && scope->type == Scope::ScopeType::eNamespace) {
|
||||||
scope = scope->nestedIn;
|
scope = scope->nestedIn;
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -376,6 +376,7 @@ private:
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes3);
|
TEST_CASE(createSymbolDatabaseFindAllScopes3);
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes4);
|
TEST_CASE(createSymbolDatabaseFindAllScopes4);
|
||||||
TEST_CASE(createSymbolDatabaseFindAllScopes5);
|
TEST_CASE(createSymbolDatabaseFindAllScopes5);
|
||||||
|
TEST_CASE(createSymbolDatabaseFindAllScopes6);
|
||||||
|
|
||||||
TEST_CASE(enum1);
|
TEST_CASE(enum1);
|
||||||
TEST_CASE(enum2);
|
TEST_CASE(enum2);
|
||||||
|
@ -5284,6 +5285,47 @@ private:
|
||||||
TODO_ASSERT(var && var->variable());
|
TODO_ASSERT(var && var->variable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createSymbolDatabaseFindAllScopes6()
|
||||||
|
{
|
||||||
|
GET_SYMBOL_DB("class A {\n"
|
||||||
|
"public:\n"
|
||||||
|
" class Nested {\n"
|
||||||
|
" public:\n"
|
||||||
|
" virtual ~Nested() = default;\n"
|
||||||
|
" };\n"
|
||||||
|
"};\n"
|
||||||
|
"class B {\n"
|
||||||
|
"public:\n"
|
||||||
|
" class Nested {\n"
|
||||||
|
" public:\n"
|
||||||
|
" virtual ~Nested() = default;\n"
|
||||||
|
" };\n"
|
||||||
|
"};\n"
|
||||||
|
"class C : public A, public B {\n"
|
||||||
|
"public:\n"
|
||||||
|
" class Nested : public A::Nested, public B::Nested {};\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT(db);
|
||||||
|
ASSERT_EQUALS(6, db->typeList.size());
|
||||||
|
auto it = db->typeList.cbegin();
|
||||||
|
const Type& classA = *it++;
|
||||||
|
const Type& classNA = *it++;
|
||||||
|
const Type& classB = *it++;
|
||||||
|
const Type& classNB = *it++;
|
||||||
|
const Type& classC = *it++;
|
||||||
|
const Type& classNC = *it++;
|
||||||
|
ASSERT(classA.name() == "A" && classB.name() == "B" && classC.name() == "C");
|
||||||
|
ASSERT(classNA.name() == "Nested" && classNB.name() == "Nested" && classNC.name() == "Nested");
|
||||||
|
ASSERT(classA.derivedFrom.empty() && classB.derivedFrom.empty());
|
||||||
|
ASSERT_EQUALS(classC.derivedFrom.size(), 2U);
|
||||||
|
ASSERT_EQUALS(classC.derivedFrom[0].type, &classA);
|
||||||
|
ASSERT_EQUALS(classC.derivedFrom[1].type, &classB);
|
||||||
|
ASSERT(classNA.derivedFrom.empty() && classNB.derivedFrom.empty());
|
||||||
|
ASSERT_EQUALS(classNC.derivedFrom.size(), 2U);
|
||||||
|
ASSERT_EQUALS(classNC.derivedFrom[0].type, &classNA);
|
||||||
|
ASSERT_EQUALS(classNC.derivedFrom[1].type, &classNB);
|
||||||
|
}
|
||||||
|
|
||||||
void enum1() {
|
void enum1() {
|
||||||
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");
|
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue