Fix endless recursion within CheckClass::isConstMemberFunc() caused by incomplete/missing template declaration
This commit is contained in:
parent
bf335217cd
commit
70885c78e4
|
@ -1737,7 +1737,7 @@ bool CheckClass::isConstMemberFunc(const Scope *scope, const Token *tok) const
|
||||||
const Type *derivedFrom = scope->definedType->derivedFrom[i].type;
|
const Type *derivedFrom = scope->definedType->derivedFrom[i].type;
|
||||||
|
|
||||||
// find the function in the base class
|
// find the function in the base class
|
||||||
if (derivedFrom && derivedFrom->classScope) {
|
if (derivedFrom && derivedFrom->classScope && !derivedFrom->hasCircularDependencies()) {
|
||||||
if (isConstMemberFunc(derivedFrom->classScope, tok))
|
if (isConstMemberFunc(derivedFrom->classScope, tok))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4808,6 +4808,25 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (performance, inconclusive) Technically the member function 'MixerParticipant::InitializeFileReader' can be static.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (performance, inconclusive) Technically the member function 'MixerParticipant::InitializeFileReader' can be static.\n", errout.str());
|
||||||
|
|
||||||
|
// Based on an example from SVN source code causing an endless recursion within CheckClass::isConstMemberFunc()
|
||||||
|
// A more complete example including a template declaration like
|
||||||
|
// template<typename K> class Hash{/* ... */};
|
||||||
|
// didn't .
|
||||||
|
checkConst("template<>\n"
|
||||||
|
"class Hash<void> {\n"
|
||||||
|
"protected:\n"
|
||||||
|
" typedef Key::key_type key_type;\n"
|
||||||
|
" void set(const Key& key);\n"
|
||||||
|
"};\n"
|
||||||
|
"template<typename K, int KeySize>\n"
|
||||||
|
"class Hash : private Hash<void> {\n"
|
||||||
|
" typedef Hash<void> inherited;\n"
|
||||||
|
" void set(const Key& key) {\n"
|
||||||
|
" inherited::set(inherited::Key(key));\n"
|
||||||
|
" }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue