Commit 1faf2bd1 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

C++: Fix resolving of using in enclosing scope

Use-case:
namespace Ns {
namespace Nested {
struct Foo
{
    void func();
    int bar;
};
}
}

using namespace Ns::Nested;

namespace Ns
{
void Foo::func()
{
    bar; // bar not highlighted
}
}

Change-Id: I6e667d63eb40511d65532c4d6d317aa4028a87a4
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 28e163de
......@@ -1021,7 +1021,7 @@ LookupScope *LookupScope::lookupType(const Name *name, Block *block)
LookupScope *LookupScope::findType(const Name *name)
{
ProcessedSet processed;
return d->lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ false, d);
return d->lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ true, d);
}
LookupScope *Internal::LookupScopePrivate::findBlock_helper(
......
......@@ -1551,6 +1551,29 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("C")
<< QLatin1String("m"));
QTest::newRow("type_and_using_declaration: type in nested namespace and using in global") << _(
"namespace Ns {\n"
"namespace Nested {\n"
"struct Foo\n"
"{\n"
" void func();\n"
" int m_bar;\n"
"};\n"
"}\n"
"}\n"
"\n"
"using namespace Ns::Nested;\n"
"\n"
"namespace Ns\n"
"{\n"
"void Foo::func()\n"
"{\n"
" @\n"
"}\n"
"}\n"
) << _("m_") << (QStringList()
<< QLatin1String("m_bar"));
QTest::newRow("instantiate_template_with_anonymous_class") << _(
"template <typename T>\n"
"struct S\n"
......
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