forked from OSchip/llvm-project
objc-arc: bridge casts in non-arc mode are now
error. // rdar://10597832 llvm-svn: 146918
This commit is contained in:
parent
fee6e493b0
commit
f9aca2089e
|
@ -326,9 +326,8 @@ def err_illegal_super_cast : Error<
|
|||
let CategoryName = "ARC Parse Issue" in {
|
||||
def err_arc_bridge_retain : Error<
|
||||
"unknown cast annotation __bridge_retain; did you mean __bridge_retained?">;
|
||||
def warn_arc_bridge_retain : Warning<
|
||||
"bridge casts will have no effect in non-arc mode and will be ignored">,
|
||||
InGroup<DiagGroup<"bridge-casts-non-arc-mode">>;
|
||||
def err_arc_bridge_cast : Error<
|
||||
"bridge casts will have no effect in non-arc mode">;
|
||||
}
|
||||
|
||||
def err_objc_illegal_visibility_spec : Error<
|
||||
|
|
|
@ -1826,7 +1826,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
|||
if (BridgeCast && !getLang().ObjCAutoRefCount) {
|
||||
SourceLocation BridgeKeywordLoc = ConsumeToken();
|
||||
if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
|
||||
Diag(BridgeKeywordLoc, diag::warn_arc_bridge_retain)
|
||||
Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast)
|
||||
<< FixItHint::CreateReplacement(BridgeKeywordLoc,
|
||||
"");
|
||||
BridgeCast = false;
|
||||
|
|
|
@ -14,7 +14,13 @@ CFStringRef CFGetString();
|
|||
id CreateSomething();
|
||||
NSString *CreateNSString();
|
||||
|
||||
typedef int array0[sizeof((__bridge id)CFCreateSomething())];
|
||||
typedef int array1[sizeof((__bridge CFTypeRef)CreateSomething())];
|
||||
#if __has_feature(objc_arc)
|
||||
#define BRIDGE __bridge
|
||||
#else
|
||||
#define BRIDGE
|
||||
#endif
|
||||
|
||||
typedef int array0[sizeof((BRIDGE id)CFCreateSomething())];
|
||||
typedef int array1[sizeof((BRIDGE CFTypeRef)CreateSomething())];
|
||||
|
||||
|
||||
|
|
|
@ -16,19 +16,19 @@ id CreateSomething();
|
|||
NSString *CreateNSString();
|
||||
|
||||
void from_cf() {
|
||||
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
(__bridge int*)CFCreateSomething(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}} \
|
||||
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
(__bridge int*)CFCreateSomething(); // expected-error {{bridge casts will have no effect in non-arc mode}} \
|
||||
// expected-warning {{expression result unused}}
|
||||
id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
id obj3 = (__bridge id)CFGetSomething(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
id obj4 = (__bridge NSString*)CFGetString(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
}
|
||||
|
||||
void to_cf(id obj) {
|
||||
CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{bridge casts will have no effect in non-arc mode and will be ignored}}
|
||||
CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-error {{bridge casts will have no effect in non-arc mode}}
|
||||
}
|
||||
|
||||
void fixits() {
|
||||
|
|
Loading…
Reference in New Issue