From ec4d242bb3ed17eff793f591ff8184f378380ef0 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 31 May 2015 20:07:49 +0300 Subject: [PATCH] C++: Fix resolving of templated partial specialization Use-case: template struct t {}; template struct s { float f; }; template struct s> { int i; }; void f() { s> var; var.i; // i not highlighted } Task-number: QTCREATORBUG-14034 Change-Id: I5d00bc3247352fca4af4c41a47c208ec3e193c8e Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/LookupContext.cpp | 7 +++++++ src/plugins/cpptools/cppcompletion_test.cpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index dc96c304a59..2afe046ac0f 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -1215,6 +1215,13 @@ LookupScopePrivate *LookupScopePrivate::findSpecialization( if (specializationTemplateArgument == initializationTemplateArgument) 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; + } + } } } } diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 82a58d4760f..d8bd4101e23 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -2637,6 +2637,21 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("i") << QLatin1String("s")); + QTest::newRow("partial_specialization_templated_argument") << _( + "template struct t {};\n" + "\n" + "template struct s { float f; };\n" + "template struct s> { int i; };\n" + "\n" + "void f()\n" + "{\n" + " s> var;\n" + " @\n" + "}\n" + ) << _("var.") << (QStringList() + << QLatin1String("i") + << QLatin1String("s")); + QTest::newRow("auto_declaration_in_if_condition") << _( "struct Foo { int bar; };\n" "void fun() {\n"