aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-21 10:41:20 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-21 10:41:20 +0000
commit2b194418b83ecbe670a6e5a8e57b84f32d8b123b (patch)
tree699af03afb9557db919ab78044d82ccb44f4be93
parent944ebc63c7b995864982366f31c07685d2aed509 (diff)
Reorganize the base-lookup bits of ActOnMemInitializer in order to better
support diagnostics and error recovery. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91825 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 674a4bd956..7343e9f2e7 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1002,16 +1002,32 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
}
// It didn't name a member, so see if it names a class.
QualType BaseType;
-
TypeSourceInfo *TInfo = 0;
- if (TemplateTypeTy)
+
+ if (TemplateTypeTy) {
BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
- else
- BaseType = QualType::getFromOpaquePtr(getTypeName(*MemberOrBase, IdLoc,
- S, &SS));
- if (BaseType.isNull())
- return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
- << MemberOrBase << SourceRange(IdLoc, RParenLoc);
+ } else {
+ LookupResult R(*this, MemberOrBase, IdLoc, LookupOrdinaryName);
+ LookupParsedName(R, S, &SS);
+
+ TypeDecl *TyD = R.getAsSingle<TypeDecl>();
+ if (!TyD) {
+ if (R.isAmbiguous()) return true;
+
+ Diag(IdLoc, diag::err_mem_init_not_member_or_class)
+ << MemberOrBase << SourceRange(IdLoc, RParenLoc);
+ return true;
+ }
+
+ BaseType = Context.getTypeDeclType(TyD);
+ if (SS.isSet()) {
+ NestedNameSpecifier *Qualifier =
+ static_cast<NestedNameSpecifier*>(SS.getScopeRep());
+
+ // FIXME: preserve source range information
+ BaseType = Context.getQualifiedNameType(Qualifier, BaseType);
+ }
+ }
if (!TInfo)
TInfo = Context.getTrivialTypeSourceInfo(BaseType, IdLoc);