[cfe-commits] r91825 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp
John McCall
rjmccall at apple.com
Mon Dec 21 02:41:21 PST 2009
Author: rjmccall
Date: Mon Dec 21 04:41:20 2009
New Revision: 91825
URL: http://llvm.org/viewvc/llvm-project?rev=91825&view=rev
Log:
Reorganize the base-lookup bits of ActOnMemInitializer in order to better
support diagnostics and error recovery.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=91825&r1=91824&r2=91825&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec 21 04:41:20 2009
@@ -1002,16 +1002,32 @@
}
// 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);
More information about the cfe-commits
mailing list