Commit 4e1d2819 authored by Nikolai Kosjar's avatar Nikolai Kosjar

C++: Fix crash on invalid function qualified name

Task-number: QTCREATORBUG-14135
Change-Id: I94e850f729bd3dbf4212960c7a980a1f118030b4
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 66c29ea8
......@@ -1706,7 +1706,10 @@ bool CreateBindings::visit(Declaration *decl)
bool CreateBindings::visit(Function *function)
{
ClassOrNamespace *previous = _currentClassOrNamespace;
_currentClassOrNamespace = lookupType(function, previous);
ClassOrNamespace *binding = lookupType(function, previous);
if (!binding)
return false;
_currentClassOrNamespace = binding;
for (unsigned i = 0, count = function->memberCount(); i < count; ++i) {
Symbol *s = function->memberAt(i);
if (Block *b = s->asBlock())
......
......@@ -194,6 +194,8 @@ private slots:
void test_checksymbols_infiniteLoop_data();
void test_checksymbols_infiniteLoop();
void test_parentOfBlock();
};
void tst_CheckSymbols::test_checksymbols()
......@@ -1774,6 +1776,19 @@ void tst_CheckSymbols::test_checksymbols_infiniteLoop()
TestCase::runCheckSymbols(document1, snapshot);
}
void tst_CheckSymbols::test_parentOfBlock()
{
const QByteArray source = "void C::f()\n"
"{\n"
" enum E { e1 };\n"
"}\n";
const Document::Ptr document = TestCase::createDocument(QLatin1String("file1.cpp"), source);
Snapshot snapshot;
snapshot.insert(document);
TestCase::runCheckSymbols(document, snapshot);
}
void tst_CheckSymbols::test_checksymbols_infiniteLoop_data()
{
QTest::addColumn<QByteArray>("source1");
......
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