C++: Support default template argument lookup for specialization

This fixes std::vector, although it doesn't really resolve numeric
template arguments. It just picks the first specialization.

Use-case:
class Foo {};
template<class T1 = Foo> class Temp;
template<> class Temp<Foo> { int var; };
void func()
{
    Temp<> t;
    t.var; // var not highlighted
}

Task-number: QTCREATORBUG-8922
Change-Id: I593515beb3a6d901b6088db8bc1b8e16c39083d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-06-07 11:47:50 +03:00
committed by Orgad Shaneh
parent 1c7e465c30
commit 97d3d9ac09
3 changed files with 74 additions and 40 deletions

View File

@@ -2689,6 +2689,19 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("f")
<< QLatin1String("and_type"));
QTest::newRow("specialization_with_default_value") << _(
"class Foo {};\n"
"template<class T1 = Foo> class Temp;\n"
"template<> class Temp<Foo> { int var; };\n"
"void func()\n"
"{\n"
" Temp<> t;\n"
" @\n"
"}\n"
) << _("t.") << (QStringList()
<< QLatin1String("var")
<< QLatin1String("Temp"));
QTest::newRow("auto_declaration_in_if_condition") << _(
"struct Foo { int bar; };\n"
"void fun() {\n"