Commit e53f4352 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Erik Verbruggen

Fix crashes when cyclic inheritance

More complex situation.
Base class is a template and derived class is a template.

Task-number: QTCREATORBUG-8072
Task-number: QTCREATORBUG-7962
Change-Id: I7e8aa727fccd2bd4a779e6fe781553cd12196682
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 40a6f0b1
......@@ -58,7 +58,15 @@ public:
}
bool contains(const T *item)
{
return _container.contains(item);
if (_container.contains(item))
return true;
foreach (const T *existingItem, _container) {
if (existingItem->isEqualTo(item))
return true;
}
return false;
}
void clear(const T *item)
......
......@@ -930,4 +930,43 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
QTest::newRow("case: indirect cyclic inheritance with templates")
<< code << completions;
completions.clear();
code = "\n"
"namespace NS\n"
"{\n"
"template <typename T> struct SuperClass\n"
"{\n"
" typedef T Type;\n"
" Type super_class_type;\n"
"};\n"
"}\n"
"\n"
"template <typename T>\n"
"struct Class;\n"
"\n"
"template <typename T, typename S>\n"
"struct ClassRecurse : Class<S>\n"
"{\n"
" T class_recurse_t;\n"
" S class_recurse_s;\n"
"};\n"
"\n"
"template <typename T>\n"
"struct Class : ClassRecurse< T, typename ::NS::SuperClass<T>::Type >\n"
"{\n"
" T class_t;\n"
"};\n"
"\n"
"Class<int> c;\n"
"c.\n"
"@\n"
;
completions.append("Class");
completions.append("ClassRecurse");
completions.append("class_t");
completions.append("class_recurse_s");
completions.append("class_recurse_t");
QTest::newRow("case: direct cyclic inheritance with templates, more complex situation")
<< code << completions;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment