• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks -verify %s
2// rdar://10597832
3
4typedef const void *CFTypeRef;
5typedef const struct __CFString *CFStringRef;
6
7@interface NSString
8@end
9
10CFTypeRef CFCreateSomething();
11CFStringRef CFCreateString();
12CFTypeRef CFGetSomething();
13CFStringRef CFGetString();
14
15id CreateSomething();
16NSString *CreateNSString();
17
18void from_cf() {
19  id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
20  id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
21  (__bridge int*)CFCreateSomething();  // expected-warning {{'__bridge' casts have no effect when not using ARC}}  \
22                                       // expected-warning {{expression result unused}}
23  id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
24  id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
25}
26
27void to_cf(id obj) {
28  CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
29  CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
30  CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
31  CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
32}
33
34void fixits() {
35  id obj1 = (id)CFCreateSomething();
36  CFTypeRef cf1 = (CFTypeRef)CreateSomething();
37}
38
39#pragma clang diagnostic ignored "-Warc-bridge-casts-disallowed-in-nonarc"
40
41void to_cf_ignored(id obj) {
42  CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // no-warning
43  CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
44}
45