diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 967547e0d4ac7d8ae65f79f106e682fedd77a343..c4d5d66ad432b03fd8e6327d067b47b8d790a0f2 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -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: