diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-26 19:22:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-26 19:22:42 +0000 |
commit | 2cf738f1944d1cc724ea7561b84440a3a1059e45 (patch) | |
tree | c6ecb9d3ffa2aa6b2f2fd15c5b996869e3e48b83 /lib/Sema/SemaExprCXX.cpp | |
parent | e9f42087aabfdb6b2afc35c7e38ac65da063b409 (diff) |
More support for pseudo dtors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80129 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index cf52bae86c..2b0749aec0 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1694,18 +1694,35 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base, const CXXScopeSpec *SS) { if (SS && SS->isInvalid()) return ExprError(); + + Expr *BaseExpr = (Expr *)Base.get(); - // Since this might be a postfix expression, get rid of ParenListExprs. - Base = MaybeConvertParenListExprToParenExpr(S, move(Base)); - - Expr *BaseExpr = Base.takeAs<Expr>(); - assert(BaseExpr && "no record expression"); + if (BaseExpr->isTypeDependent() || + (SS && isDependentScopeSpecifier(*SS))) { + // FIXME: Return an unresolved ref expr. + return ExprError(); + } + + TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, SS); + if (!BaseTy) { + Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) + << ClassName; + return ExprError(); + } - // Perform default conversions. - DefaultFunctionArrayConversion(BaseExpr); + QualType BaseType = GetTypeFromParser(BaseTy); + if (!BaseType->isRecordType()) { + Diag(ClassNameLoc, diag::err_type_in_pseudo_dtor_not_a_class_type) + << BaseType; + return ExprError(); + } - QualType BaseType = BaseExpr->getType(); - return ExprError(); + CanQualType CanBaseType = Context.getCanonicalType(BaseType); + DeclarationName DtorName = + Context.DeclarationNames.getCXXDestructorName(CanBaseType); + + return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, ClassNameLoc, + DtorName, DeclPtrTy(), SS); } Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { |