summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-06 22:13:31 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-06 22:13:31 +0000
commit11d0c4c0985fc37a844c0c3033db9f49291e2e1f (patch)
tree4437dd5182125f02765bdb5e19309bd3cacf0e1f /clang/lib/Parse/ParseExpr.cpp
parent193e4c025efda046c3db4be1efb098a491767ff9 (diff)
downloadbcm5719-llvm-11d0c4c0985fc37a844c0c3033db9f49291e2e1f.tar.gz
bcm5719-llvm-11d0c4c0985fc37a844c0c3033db9f49291e2e1f.zip
Parsing, ASTs, and semantic analysis for the declaration of overloaded
operators in C++. Overloaded operators can be called directly via their operator-function-ids, e.g., "operator+(foo, bar)", but we don't yet implement the semantics of operator overloading to handle, e.g., "foo + bar". llvm-svn: 58817
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index b7376954d93..49c28eec75a 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -356,7 +356,8 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
/// [GNU] '__extension__' '__real' '__imag'
///
/// primary-expression: [C99 6.5.1]
-/// identifier
+/// [C99] identifier
+// [C++] id-expression
/// constant
/// string-literal
/// [C++] boolean-literal [C++ 2.13.5]
@@ -390,6 +391,16 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
/// enumeration-constant -> identifier
/// character-constant
///
+/// id-expression: [C++ 5.1]
+/// unqualified-id
+/// qualified-id [TODO]
+///
+/// unqualified-id: [C++ 5.1]
+/// identifier
+/// operator-function-id
+/// conversion-function-id [TODO]
+/// '~' class-name [TODO]
+/// template-id [TODO]
Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
ExprResult Res;
tok::TokenKind SavedKind = Tok.getKind();
@@ -461,6 +472,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
}
// primary-expression: identifier
+ // unqualified-id: identifier
// constant: enumeration-constant
// Consume the identifier so that we can see if it is followed by a '('.
@@ -589,6 +601,17 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
return ParsePostfixExpressionSuffix(Res);
}
+ case tok::kw_operator: {
+ SourceLocation OperatorLoc = Tok.getLocation();
+ if (IdentifierInfo *II = MaybeParseOperatorFunctionId()) {
+ Res = Actions.ActOnIdentifierExpr(CurScope, OperatorLoc, *II,
+ Tok.is(tok::l_paren));
+ // These can be followed by postfix-expr pieces.
+ return ParsePostfixExpressionSuffix(Res);
+ }
+ break;
+ }
+
case tok::at: {
SourceLocation AtLoc = ConsumeToken();
return ParseObjCAtExpression(AtLoc);
OpenPOWER on IntegriCloud