diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-25 23:46:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-25 23:46:41 +0000 |
commit | ec7738776ba68576db5d8316af399d1f983245ee (patch) | |
tree | 9597acbccf36814092f996cad8abd2a9c3a42b0f | |
parent | 11401c6611554d9f43e1fbdc38bb39b09321604d (diff) |
Parsing of pseudo-destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80055 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Action.h | 11 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 32 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 24 |
5 files changed, 66 insertions, 10 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 3287e634eb..0146298c72 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -1263,7 +1263,16 @@ public: return ExprEmpty(); } - + virtual OwningExprResult + ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + SourceLocation ClassNameLoc, + IdentifierInfo *ClassName, + const CXXScopeSpec *SS = 0) { + return ExprEmpty(); + } + /// ActOnFinishFullExpr - Called whenever a full expression has been parsed. /// (C++ [intro.execution]p12). virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr) { diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 7303f57dde..16d3511dd7 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -933,18 +933,34 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { ParseOptionalCXXScopeSpecifier(SS); } - if (Tok.isNot(tok::identifier)) { + if (Tok.is(tok::identifier)) { + if (!LHS.isInvalid()) + LHS = Actions.ActOnMemberReferenceExpr(CurScope, move(LHS), OpLoc, + OpKind, Tok.getLocation(), + *Tok.getIdentifierInfo(), + ObjCImpDecl, &SS); + } else if (getLang().CPlusPlus && Tok.is(tok::tilde)) { + // We have a C++ pseudo-destructor. + + // Consume the tilde. + ConsumeToken(); + + if (!Tok.is(tok::identifier)) { + Diag(Tok, diag::err_expected_ident); + return ExprError(); + } + + if (!LHS.isInvalid()) + LHS = Actions.ActOnPseudoDtorReferenceExpr(CurScope, move(LHS), + OpLoc, OpKind, + Tok.getLocation(), + Tok.getIdentifierInfo(), + &SS); + } else { Diag(Tok, diag::err_expected_ident); return ExprError(); } - if (!LHS.isInvalid()) { - LHS = Actions.ActOnMemberReferenceExpr(CurScope, move(LHS), OpLoc, - OpKind, Tok.getLocation(), - *Tok.getIdentifierInfo(), - ObjCImpDecl, &SS); - } - if (getLang().CPlusPlus) Actions.ActOnCXXExitMemberScope(CurScope, MemberSS); diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 9db3fae036..7a11a60302 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1921,6 +1921,14 @@ public: TypeTy *Ty, SourceLocation RParen); + virtual OwningExprResult + ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + SourceLocation ClassNameLoc, + IdentifierInfo *ClassName, + const CXXScopeSpec *SS = 0); + /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is /// non-empty, will create a new CXXExprWithTemporaries expression. /// Otherwise, just returs the passed in expression. diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f6ad2a6c69..b670cf7a28 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1958,7 +1958,6 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation MemberLoc, IdentifierInfo &Member, DeclPtrTy ObjCImpDecl, const CXXScopeSpec *SS) { - // FIXME: handle the CXXScopeSpec for proper lookup of qualified-ids if (SS && SS->isInvalid()) return ExprError(); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index aefec6a7a6..a714f327d4 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1682,11 +1682,35 @@ Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr, return E; } +Sema::OwningExprResult +Sema::ActOnPseudoDtorReferenceExpr(Scope *S, ExprArg Base, + SourceLocation OpLoc, + tok::TokenKind OpKind, + SourceLocation ClassNameLoc, + IdentifierInfo *ClassName, + const CXXScopeSpec *SS) { + if (SS && SS->isInvalid()) + return ExprError(); + + // 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"); + + // Perform default conversions. + DefaultFunctionArrayConversion(BaseExpr); + + QualType BaseType = BaseExpr->getType(); + return ExprError(); +} + Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { Expr *FullExpr = Arg.takeAs<Expr>(); if (FullExpr) FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr, /*ShouldDestroyTemps=*/true); + return Owned(FullExpr); } |