1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
2 // RUN: not %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
5 typedef const struct __CFString * CFStringRef;
6 typedef struct __CFString * CFMutableStringRef;
7 typedef signed long CFIndex;
8 typedef const struct __CFAllocator * CFAllocatorRef;
10 extern const CFStringRef kCFBundleNameKey;
12 @protocol NSCopying @end
14 @interface NSDictionary
15 - (id)objectForKeyedSubscript:(id<NSCopying>)key;
18 #pragma clang arc_cf_code_audited begin
20 CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength);
21 #pragma clang arc_cf_code_audited end
23 typedef const void * CFTypeRef;
25 id CFBridgingRelease(CFTypeRef __attribute__((cf_consumed)) X);
27 @interface NSMutableString @end
29 NSMutableString *test() {
30 NSDictionary *infoDictionary;
31 infoDictionary[kCFBundleNameKey] = 0; // expected-error {{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} \
32 // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \
33 // expected-note {{use __bridge to convert directly (no change in ownership)}} \
34 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
35 return infoDictionary[CFStringCreateMutable(((void*)0), 100)]; // expected-error {{indexing expression is invalid because subscript type 'CFMutableStringRef' (aka 'struct __CFString *') is not an integral or Objective-C pointer type}} \
36 // expected-error {{implicit conversion of C pointer type 'CFMutableStringRef' (aka 'struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \
37 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFMutableStringRef' (aka 'struct __CFString *') into ARC}}
41 // CHECK: fix-it:"{{.*}}":{31:18-31:18}:"(__bridge __strong id<NSCopying>)("
42 // CHECK: fix-it:"{{.*}}":{31:34-31:34}:")"
43 // CHECK: fix-it:"{{.*}}":{31:18-31:18}:"CFBridgingRelease("
44 // CHECK: fix-it:"{{.*}}":{31:34-31:34}:")"
45 // CHECK: fix-it:"{{.*}}":{35:25-35:25}:"CFBridgingRelease("
46 // CHECK: fix-it:"{{.*}}":{35:63-35:63}:")"