From 90efa0f174ba4ecc0853ef065075f1d363edd22c Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 4 Jun 2009 12:18:05 +0200
Subject: [PATCH] Check nested name specifiers.

---
 src/plugins/cpptools/cppmodelmanager.cpp | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 967547e0d4a..c4d5d66ad43 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:
-- 
GitLab