C++: Fix crash in typedef resolving

Task-number: QTCREATORBUG-9990

Change-Id: I8153f18c8b7402c5cb3edbe41098792be183de44
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-08-16 12:47:03 +02:00
committed by Kai Koehne
parent 92a37e2614
commit f4c6eae3bb

View File

@@ -894,6 +894,8 @@ private:
static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope) static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope)
{ {
QList<LookupItem> results; QList<LookupItem> results;
if (!scope)
return results;
Scope *enclosingBlockScope = 0; Scope *enclosingBlockScope = 0;
for (Block *block = scope->asBlock(); block; for (Block *block = scope->asBlock(); block;
block = enclosingBlockScope ? enclosingBlockScope->asBlock() : 0) { block = enclosingBlockScope ? enclosingBlockScope->asBlock() : 0) {
@@ -977,7 +979,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
TypedefsResolver typedefsResolver(_context); TypedefsResolver typedefsResolver(_context);
foreach (const LookupItem &r, baseResults) { foreach (const LookupItem &r, baseResults) {
if (!r.type().type()) if (!r.type().type() || !r.scope())
continue; continue;
FullySpecifiedType ty = r.type().simplified(); FullySpecifiedType ty = r.type().simplified();
FullySpecifiedType originalType = ty; FullySpecifiedType originalType = ty;