mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
Only accept __bridge_retain in system headers, as Doug suggested.
llvm-svn: 133300
This commit is contained in:
parent
03cb993560
commit
0c07bee8bd
@ -263,6 +263,11 @@ def warn_objc_protocol_qualifier_missing_id : Warning<
|
||||
def err_objc_unknown_at : Error<"expected an Objective-C directive after '@'">;
|
||||
def err_illegal_super_cast : Error<
|
||||
"cannot cast 'super' (it isn't an expression)">;
|
||||
|
||||
let CategoryName = "Automatic Reference Counting Issue" in {
|
||||
def err_arc_bridge_retain : Error<
|
||||
"unknown cast annotation __bridge_retain; did you mean __bridge_retained?">;
|
||||
}
|
||||
|
||||
def err_objc_illegal_visibility_spec : Error<
|
||||
"illegal visibility specification">;
|
||||
|
@ -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());
|
||||
|
@ -40,3 +40,13 @@ extern struct Test6 *const kMagicConstant;
|
||||
@interface Test7
|
||||
@property id *prop;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static inline void *test8(id ptr) {
|
||||
return (__bridge_retain void*) ptr;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ void to_cf(id obj) {
|
||||
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
|
||||
|
||||
// rdar://problem/9629566 - temporary workaround
|
||||
CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething();
|
||||
CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething(); // expected-error {{unknown cast annotation __bridge_retain; did you mean __bridge_retained?}}
|
||||
}
|
||||
|
||||
void fixits() {
|
||||
|
@ -46,3 +46,5 @@ void test7(Test7 *p) {
|
||||
[p setProp: 0]; // expected-error {{'setProp:' is unavailable: this system declaration uses an unsupported type}}
|
||||
}
|
||||
#endif
|
||||
|
||||
// test8 in header
|
||||
|
Loading…
Reference in New Issue
Block a user