aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5119388dbc..468e95523c 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -39,12 +39,28 @@ Sema::TypeTy *Sema::isTypeName(IdentifierInfo &II, Scope *S,
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);
+
+ 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 (IIDecl && (isa<TypedefDecl>(IIDecl) ||
- isa<ObjCInterfaceDecl>(IIDecl) ||
- isa<TagDecl>(IIDecl) ||
- isa<TemplateTypeParmDecl>(IIDecl)))
+ if (isa<TypedefDecl>(IIDecl) ||
+ isa<ObjCInterfaceDecl>(IIDecl) ||
+ isa<TagDecl>(IIDecl) ||
+ isa<TemplateTypeParmDecl>(IIDecl))
return IIDecl;
return 0;
}