From: John McCall Date: Mon, 21 Dec 2009 10:41:20 +0000 (+0000) Subject: Reorganize the base-lookup bits of ActOnMemInitializer in order to better X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b194418b83ecbe670a6e5a8e57b84f32d8b123b;p=clang 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 --- 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(); + 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(SS.getScopeRep()); + + // FIXME: preserve source range information + BaseType = Context.getQualifiedNameType(Qualifier, BaseType); + } + } if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(BaseType, IdLoc);