From b67ebf9ffce6bbba7952b36120f49d7abf956e66 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 22 May 2015 13:03:55 +0300 Subject: C++: Fix lookup for instantiation of using Yet another std::vector issue... Use-cases: // Case 1 template using type = T; // Case 2 struct Parent { template using type = T; }; // Case 3 template struct ParentT { template using type = DT; }; struct Foo { int bar; }; void func() { type p1; Parent::type p2; ParentT::type p3; // bar not highlighted p1.bar; p2.bar; p3.bar; } Task-number: QTCREATORBUG-14480 Change-Id: I9ab08ea7360a432c48eb4b85aa0d63e08d2464c1 Reviewed-by: Nikolai Kosjar --- src/plugins/cpptools/cppcompletion_test.cpp | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'src/plugins/cpptools/cppcompletion_test.cpp') diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 00b796f0a8..cc98254c76 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -2917,6 +2917,87 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("Foo") << QLatin1String("bar")); + QTest::newRow("template_using_instantiation") << _( + "template\n" + "using T = _Tp;\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " T p;\n" + " @\n" + "}\n" + ) << _("p.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("nested_template_using_instantiation") << _( + "struct Parent {\n" + " template\n" + " using T = _Tp;\n" + "};\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " Parent::T p;\n" + " @;\n" + "}\n" + ) << _("p.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("nested_template_using_instantiation_in_template_class") << _( + "template\n" + "struct Parent {\n" + " template\n" + " using T = _Tp;\n" + "};\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " Parent::T p;\n" + " @;\n" + "}\n" + ) << _("p.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("recursive_nested_template_using_instantiation") << _( + "struct Foo { int bar; };\n" + "\n" + "struct A { typedef Foo value_type; };\n" + "\n" + "template\n" + "struct Traits\n" + "{\n" + " typedef Foo value_type;\n" + "\n" + " template\n" + " using U = T;\n" + "};\n" + "\n" + "template\n" + "struct Temp\n" + "{\n" + " typedef Traits TraitsT;\n" + " typedef typename T::value_type value_type;\n" + " typedef typename TraitsT::template U rebind;\n" + "};\n" + "\n" + "void func()\n" + "{\n" + " typename Temp::rebind>::value_type p;\n" + " @\n" + "}\n" + ) << _("p.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + QTest::newRow("qualified_name_in_nested_type") << _( "template\n" "struct Temp {\n" -- cgit v1.2.1