Commit fb550c4f authored by Leandro Melo's avatar Leandro Melo Committed by Leandro T. C. Melo

C++: Fix crash when typing illegal class names

Such as class ~A {} or class operator+ {}.

Done by Roberto Raggi

Change-Id: I4fdad6d27aaa997e651f2d08de36fe675fc78814
Reviewed-on: http://codereview.qt.nokia.com/2778Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent a9c0d445
......@@ -2771,6 +2771,21 @@ bool Bind::visit(ClassSpecifierAST *ast)
startScopeOffset = tokenAt(q->unqualified_name->lastToken() - 1).end(); // at the end of the unqualified name
}
}
// get the unqualified class name
const QualifiedNameId *q = className->asQualifiedNameId();
const Name *unqualifiedClassName = q ? q->name() : className;
if (! unqualifiedClassName) // paranoia check
className = 0;
else if (! (unqualifiedClassName->isNameId() || unqualifiedClassName->isTemplateNameId())) {
translationUnit()->error(sourceLocation, "expected a class-name");
className = unqualifiedClassName->identifier();
if (q && className)
className = control()->qualifiedNameId(q->base(), className);
}
}
Class *klass = control()->newClass(sourceLocation, className);
......
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