C++: fix auto declaration in if condition

Fix for auto completion in case of auto declaration inside if condition:

struct Foo { int bar; };
void func()
{
    if (auto s = new Foo)
        s->; // auto completion does not work
}

Task-number: QTCREATORBUG-13805
Change-Id: Ia1776e8cc04e6040a6bf5f43cf82cfd6ce6dde7a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Przemyslaw Gorszkowski
2015-02-02 15:13:00 +01:00
parent 7d4b9c4ba0
commit 955e28f954
2 changed files with 20 additions and 0 deletions

View File

@@ -2384,6 +2384,17 @@ void CppToolsPlugin::test_completion_data()
"}\n"
) << _("s.") << (QStringList()
<< QLatin1String("S"));
QTest::newRow("auto_declaration_in_if_condition") << _(
"struct Foo { int bar; };\n"
"void fun() {\n"
" if (auto s = new Foo) {\n"
" @\n"
" }\n"
"}\n"
) << _("s->") << (QStringList()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
}
void CppToolsPlugin::test_completion_member_access_operator()