| 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 |
| 3 |
|
| 4 |
typedef const struct __CFString * CFStringRef; |
| 5 |
typedef struct __CFString * CFMutableStringRef; |
| 6 |
typedef signed long CFIndex; |
| 7 |
typedef const struct __CFAllocator * CFAllocatorRef; |
| 8 |
|
| 9 |
extern const CFStringRef kCFBundleNameKey; |
| 10 |
|
| 11 |
@protocol NSCopying @end |
| 12 |
|
| 13 |
@interface NSDictionary |
| 14 |
- (id)objectForKeyedSubscript:(id<NSCopying>)key; |
| 15 |
@end |
| 16 |
|
| 17 |
#pragma clang arc_cf_code_audited begin |
| 18 |
extern |
| 19 |
CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); |
| 20 |
#pragma clang arc_cf_code_audited end |
| 21 |
|
| 22 |
typedef const void * CFTypeRef; |
| 23 |
|
| 24 |
id CFBridgingRelease(CFTypeRef __attribute__((cf_consumed)) X); |
| 25 |
|
| 26 |
@interface NSMutableString @end |
| 27 |
|
| 28 |
NSMutableString *test(void) { |
| 29 |
NSDictionary *infoDictionary; |
| 30 |
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}} |
| 31 |
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}} \ |
| 32 |
// expected-error {{implicit conversion of C pointer type 'CFMutableStringRef' (aka 'struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \ |
| 33 |
// expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFMutableStringRef' (aka 'struct __CFString *') into ARC}} |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
// CHECK: fix-it:"{{.*}}":{31:25-31:25}:"CFBridgingRelease(" |
| 38 |
// CHECK: fix-it:"{{.*}}":{31:63-31:63}:")" |