parent
183f611fb6
commit
edc5106237
|
@ -755,7 +755,7 @@ void SymbolDatabase::createSymbolDatabaseClassInfo()
|
|||
for (Type& type : typeList) {
|
||||
// finish filling in base class info
|
||||
for (Type::BaseInfo & i : type.derivedFrom) {
|
||||
const Type* found = findType(i.nameTok, type.enclosingScope);
|
||||
const Type* found = findType(i.nameTok, type.enclosingScope, /*lookOutside*/ true);
|
||||
if (found && found->findDependency(&type)) {
|
||||
// circular dependency
|
||||
//mTokenizer->syntaxError(nullptr);
|
||||
|
@ -5496,7 +5496,7 @@ const Scope *SymbolDatabase::findScope(const Token *tok, const Scope *startScope
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Type* SymbolDatabase::findType(const Token *startTok, const Scope *startScope) const
|
||||
const Type* SymbolDatabase::findType(const Token *startTok, const Scope *startScope, bool lookOutside) const
|
||||
{
|
||||
// skip over struct or union
|
||||
if (Token::Match(startTok, "struct|union"))
|
||||
|
@ -5541,6 +5541,9 @@ const Type* SymbolDatabase::findType(const Token *startTok, const Scope *startSc
|
|||
type = scope1->definedType;
|
||||
if (type)
|
||||
return type;
|
||||
} else if (scope->type == Scope::ScopeType::eNamespace && lookOutside) {
|
||||
scope = scope->nestedIn;
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1373,9 +1373,9 @@ public:
|
|||
/** For unit testing only */
|
||||
const Scope *findScopeByName(const std::string& name) const;
|
||||
|
||||
const Type* findType(const Token *startTok, const Scope *startScope) const;
|
||||
Type* findType(const Token *startTok, Scope *startScope) const {
|
||||
return const_cast<Type*>(this->findType(startTok, const_cast<const Scope *>(startScope)));
|
||||
const Type* findType(const Token *startTok, const Scope *startScope, bool lookOutside = false) const;
|
||||
Type* findType(const Token *startTok, Scope *startScope, bool lookOutside = false) const {
|
||||
return const_cast<Type*>(this->findType(startTok, const_cast<const Scope *>(startScope), lookOutside));
|
||||
}
|
||||
|
||||
const Scope *findScope(const Token *tok, const Scope *startScope) const;
|
||||
|
|
|
@ -7446,6 +7446,16 @@ private:
|
|||
" void foo(int);\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOverride("struct B {\n" // #9092
|
||||
" virtual int f(int i) const = 0;\n"
|
||||
"};\n"
|
||||
"namespace N {\n"
|
||||
" struct D : B {\n"
|
||||
" virtual int f(int i) const;\n"
|
||||
" };\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:6]: (style) The function 'f' overrides a function in a base class but is not marked with a 'override' specifier.\n", errout.str());
|
||||
}
|
||||
|
||||
void overrideCVRefQualifiers() {
|
||||
|
|
Loading…
Reference in New Issue