Initial implementation of member name lookup

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62247 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5119388..468e955 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -39,12 +39,28 @@
       return 0;
     DC = static_cast<DeclContext*>(SS->getScopeRep());
   }
-  Decl *IIDecl = LookupDecl(&II, Decl::IDNS_Ordinary, S, DC, false);
+  LookupResult Result = LookupDecl(&II, Decl::IDNS_Ordinary, S, DC, false);
 
-  if (IIDecl && (isa<TypedefDecl>(IIDecl) || 
-                 isa<ObjCInterfaceDecl>(IIDecl) ||
-                 isa<TagDecl>(IIDecl) ||
-		 isa<TemplateTypeParmDecl>(IIDecl)))
+  Decl *IIDecl = 0;
+  switch (Result.getKind()) {
+  case LookupResult::NotFound:
+  case LookupResult::FoundOverloaded:
+  case LookupResult::AmbiguousBaseSubobjectTypes:
+  case LookupResult::AmbiguousBaseSubobjects:
+    // FIXME: In the event of an ambiguous lookup, we could visit all of
+    // the entities found to determine whether they are all types. This
+    // might provide better diagnostics.
+    return 0;
+
+  case LookupResult::Found:
+    IIDecl = Result.getAsDecl();
+    break;
+  }
+
+  if (isa<TypedefDecl>(IIDecl) || 
+      isa<ObjCInterfaceDecl>(IIDecl) ||
+      isa<TagDecl>(IIDecl) ||
+      isa<TemplateTypeParmDecl>(IIDecl))
     return IIDecl;
   return 0;
 }