diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 14f3805cd9..39db0e9045 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -1781,17 +1781,29 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, (Tok.is(tok::kw___bridge) || Tok.is(tok::kw___bridge_transfer) || Tok.is(tok::kw___bridge_retained) || - Tok.is(tok::kw___bridge_retain))) { // FIXME: temporary workaround + Tok.is(tok::kw___bridge_retain))) { + tok::TokenKind tokenKind = Tok.getKind(); + SourceLocation BridgeKeywordLoc = ConsumeToken(); + // Parse an Objective-C ARC ownership cast expression. ObjCBridgeCastKind Kind; - if (Tok.is(tok::kw___bridge)) + if (tokenKind == tok::kw___bridge) Kind = OBC_Bridge; - else if (Tok.is(tok::kw___bridge_transfer)) + else if (tokenKind == tok::kw___bridge_transfer) Kind = OBC_BridgeTransfer; - else + else if (tokenKind == tok::kw___bridge_retained) + Kind = OBC_BridgeRetained; + else { + // As a hopefully temporary workaround, allow __bridge_retain as + // a synonym for __bridge_retained, but only in system headers. + assert(tokenKind == tok::kw___bridge_retain); Kind = OBC_BridgeRetained; + if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc)) + Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain) + << FixItHint::CreateReplacement(BridgeKeywordLoc, + "__bridge_retained"); + } - SourceLocation BridgeKeywordLoc = ConsumeToken(); TypeResult Ty = ParseTypeName(); SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, OpenLoc); ExprResult SubExpr = ParseCastExpression(false, false, ParsedType()); |