blob: e683343cd07a6fc94f459b05b8e9a8cc6b704251 [file] [log] [blame]
Fariborz Jahaniandc483052012-08-02 18:03:58 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
Rafael Espindola96e78132013-07-04 16:16:58 +00002// RUN: not %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
Fariborz Jahaniandc483052012-08-02 18:03:58 +00003// rdar://11913153
4
5typedef const struct __CFString * CFStringRef;
6typedef struct __CFString * CFMutableStringRef;
7typedef signed long CFIndex;
8typedef const struct __CFAllocator * CFAllocatorRef;
9
10extern const CFStringRef kCFBundleNameKey;
11
12@protocol NSCopying @end
13
14@interface NSDictionary
15- (id)objectForKeyedSubscript:(id<NSCopying>)key;
16@end
17
Fariborz Jahanian7e675932012-08-02 18:38:41 +000018#pragma clang arc_cf_code_audited begin
Fariborz Jahaniandc483052012-08-02 18:03:58 +000019extern
20CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength);
Fariborz Jahanian7e675932012-08-02 18:38:41 +000021#pragma clang arc_cf_code_audited end
Fariborz Jahaniandc483052012-08-02 18:03:58 +000022
23typedef const void * CFTypeRef;
24
25id CFBridgingRelease(CFTypeRef __attribute__((cf_consumed)) X);
26
27@interface NSMutableString @end
28
29NSMutableString *test() {
30 NSDictionary *infoDictionary;
Stephen Hines0e2c34f2015-03-23 12:09:02 -070031 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}}
Fariborz Jahaniandc483052012-08-02 18:03:58 +000032 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}} \
33 // expected-error {{implicit conversion of C pointer type 'CFMutableStringRef' (aka 'struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \
Fariborz Jahaniandc483052012-08-02 18:03:58 +000034 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFMutableStringRef' (aka 'struct __CFString *') into ARC}}
35
36}
37
Stephen Hines0e2c34f2015-03-23 12:09:02 -070038// CHECK: fix-it:"{{.*}}":{32:25-32:25}:"CFBridgingRelease("
39// CHECK: fix-it:"{{.*}}":{32:63-32:63}:")"