diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-08-31 19:52:13 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-08-31 19:52:13 +0000 |
| commit | 522fbc496995e3d756bd8f77d52c745c4023d733 (patch) | |
| tree | 6725c35919a8b4d3bdd6cb89e976aebcdbb8f91c /clang/lib/Parse/ParseExpr.cpp | |
| parent | 879d7266086313b128238901246a3dbb0939b08a (diff) | |
| download | bcm5719-llvm-522fbc496995e3d756bd8f77d52c745c4023d733.tar.gz bcm5719-llvm-522fbc496995e3d756bd8f77d52c745c4023d733.zip | |
Support explicit C++ member operator syntax, from James Porter!
llvm-svn: 80608
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
| -rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 80e701e17ae..d00d6d2e33d 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -939,6 +939,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { OpKind, Tok.getLocation(), *Tok.getIdentifierInfo(), ObjCImpDecl, &SS); + ConsumeToken(); } else if (getLang().CPlusPlus && Tok.is(tok::tilde)) { // We have a C++ pseudo-destructor. @@ -946,6 +947,8 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { ConsumeToken(); if (!Tok.is(tok::identifier)) { + if (getLang().CPlusPlus) + Actions.ActOnCXXExitMemberScope(CurScope, MemberSS); Diag(Tok, diag::err_expected_ident); return ExprError(); } @@ -956,15 +959,39 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { Tok.getLocation(), Tok.getIdentifierInfo(), &SS); + ConsumeToken(); + } else if (getLang().CPlusPlus && Tok.is(tok::kw_operator)) { + if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) { + if (!LHS.isInvalid()) + LHS = Actions.ActOnOverloadedOperatorReferenceExpr(CurScope, + move(LHS), OpLoc, + OpKind, + Tok.getLocation(), + Op, &SS); + // TryParseOperatorFunctionId already consumed our token, so + // don't bother + } else if (TypeTy *ConvType = ParseConversionFunctionId()) { + if (!LHS.isInvalid()) + LHS = Actions.ActOnConversionOperatorReferenceExpr(CurScope, + move(LHS), OpLoc, + OpKind, + Tok.getLocation(), + ConvType, &SS); + } else { + if (getLang().CPlusPlus) + Actions.ActOnCXXExitMemberScope(CurScope, MemberSS); + // Don't emit a diagnostic; ParseConversionFunctionId does it for us + return ExprError(); + } } else { + if (getLang().CPlusPlus) + Actions.ActOnCXXExitMemberScope(CurScope, MemberSS); Diag(Tok, diag::err_expected_ident); return ExprError(); } if (getLang().CPlusPlus) Actions.ActOnCXXExitMemberScope(CurScope, MemberSS); - - ConsumeToken(); break; } case tok::plusplus: // postfix-expression: postfix-expression '++' |

