forked from qt-creator/qt-creator
C++: Fix resolving of templated partial specialization
Use-case:
template<class T> struct t {};
template<class> struct s { float f; };
template<class X> struct s<t<X>> { int i; };
void f()
{
s<t<char>> var;
var.i; // i not highlighted
}
Task-number: QTCREATORBUG-14034
Change-Id: I5d00bc3247352fca4af4c41a47c208ec3e193c8e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
2070431d8c
commit
ec4d242bb3
@@ -1215,6 +1215,13 @@ LookupScopePrivate *LookupScopePrivate::findSpecialization(
|
|||||||
|
|
||||||
if (specializationTemplateArgument == initializationTemplateArgument)
|
if (specializationTemplateArgument == initializationTemplateArgument)
|
||||||
return cit->second;
|
return cit->second;
|
||||||
|
|
||||||
|
if (const NamedType *specName = specializationTemplateArgument->asNamedType()) {
|
||||||
|
if (const NamedType *initName = initializationTemplateArgument->asNamedType()) {
|
||||||
|
if (specName->name()->identifier() == initName->name()->identifier())
|
||||||
|
return cit->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2637,6 +2637,21 @@ void CppToolsPlugin::test_completion_data()
|
|||||||
<< QLatin1String("i")
|
<< QLatin1String("i")
|
||||||
<< QLatin1String("s"));
|
<< QLatin1String("s"));
|
||||||
|
|
||||||
|
QTest::newRow("partial_specialization_templated_argument") << _(
|
||||||
|
"template<class T> struct t {};\n"
|
||||||
|
"\n"
|
||||||
|
"template<class> struct s { float f; };\n"
|
||||||
|
"template<class X> struct s<t<X>> { int i; };\n"
|
||||||
|
"\n"
|
||||||
|
"void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" s<t<char>> var;\n"
|
||||||
|
" @\n"
|
||||||
|
"}\n"
|
||||||
|
) << _("var.") << (QStringList()
|
||||||
|
<< QLatin1String("i")
|
||||||
|
<< QLatin1String("s"));
|
||||||
|
|
||||||
QTest::newRow("auto_declaration_in_if_condition") << _(
|
QTest::newRow("auto_declaration_in_if_condition") << _(
|
||||||
"struct Foo { int bar; };\n"
|
"struct Foo { int bar; };\n"
|
||||||
"void fun() {\n"
|
"void fun() {\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user