Commit 90efa0f1 authored by Roberto Raggi's avatar Roberto Raggi

Check nested name specifiers.

parent 45fb9726
......@@ -256,6 +256,7 @@ class Process;
class CheckUndefinedSymbols: protected ASTVisitor
{
QSet<QByteArray> _types;
QSet<QByteArray> _namespaceNames;
public:
CheckUndefinedSymbols(Document::Ptr doc)
......@@ -313,6 +314,10 @@ protected:
if (! processed->contains(binding)) {
processed->insert(binding);
if (Identifier *id = binding->identifier()) {
_namespaceNames.insert(QByteArray(id->chars(), id->size()));
}
foreach (Namespace *ns, binding->symbols) {
for (unsigned i = 0; i < ns->memberCount(); ++i) {
Symbol *member = ns->memberAt(i);
......@@ -504,6 +509,26 @@ protected:
return true;
}
virtual bool visit(QualifiedNameAST *ast)
{
if (ast->name) {
QualifiedNameId *q = ast->name->asQualifiedNameId();
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
Name *name = q->nameAt(i);
if (Identifier *id = name->identifier()) {
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (! (_namespaceNames.contains(spell) || _types.contains(spell))) {
translationUnit()->warning(ast->firstToken(),
"`%s' is not a namespace or class name",
spell.constData());
}
}
}
}
return true;
}
LookupContext lookupContext(unsigned line, unsigned column) const;
private:
......
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