aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-03-09 21:12:44 +0000
committerSteve Naroff <snaroff@apple.com>2009-03-09 21:12:44 +0000
commit61f72cbd037e58f12cfe90cd442373f44092f030 (patch)
tree77292f6d4c23460429428e75f3309d662856586f /lib/Parse/ParseExpr.cpp
parent35bd763b9438b53f7920521ed19c1ef74c7a6795 (diff)
Implement property '.' notation on Factory/Class objects. Parser changes aren't very pretty:-(
This fixes <rdar://problem/6496506> Implement class setter/getter for properties. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 331f3181cd..000cb9d606 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -569,6 +569,28 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
}
+ // Support 'Class.property' notation.
+ // We don't use isTokObjCMessageIdentifierReceiver(), since it allows
+ // 'super' (which is inappropriate here).
+ if (getLang().ObjC1 &&
+ Actions.getTypeName(*Tok.getIdentifierInfo(),
+ Tok.getLocation(), CurScope) &&
+ NextToken().is(tok::period)) {
+ IdentifierInfo &ReceiverName = *Tok.getIdentifierInfo();
+ SourceLocation IdentLoc = ConsumeToken();
+ SourceLocation DotLoc = ConsumeToken();
+
+ if (Tok.isNot(tok::identifier)) {
+ Diag(Tok, diag::err_expected_ident);
+ return ExprError();
+ }
+ IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
+ SourceLocation PropertyLoc = ConsumeToken();
+
+ Res = Actions.ActOnClassPropertyRefExpr(ReceiverName, PropertyName,
+ IdentLoc, PropertyLoc);
+ return move(Res);
+ }
// Consume the identifier so that we can see if it is followed by a '('.
// Function designators are allowed to be undeclared (C99 6.5.1p2), so we
// need to know whether or not this identifier is a function designator or