1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
2 // RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
3 // RUN: diff %t %s.result
7 typedef const struct __CFString * CFStringRef;
8 extern const CFStringRef kUTTypePlainText;
9 extern const CFStringRef kUTTypeRTF;
10 extern CFStringRef kNonConst;
12 typedef const struct __CFAllocator * CFAllocatorRef;
13 typedef const struct __CFUUID * CFUUIDRef;
15 extern const CFAllocatorRef kCFAllocatorDefault;
17 extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
20 CFStringRef sref_member;
23 @interface NSString : NSObject {
31 void f(BOOL b, id p) {
32 NSString *str = (NSString *)kUTTypePlainText; // no change
33 str = b ? kUTTypeRTF : kUTTypePlainText; // no change
34 str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change
35 str = (NSString *)p; // no change.
37 str = (__bridge NSString *)kNonConst;
38 str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst);
39 str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst);
42 NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
43 _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
44 _uuidString = CFBridgingRelease(CFRetain(_uuid));
47 @implementation NSString (StrExt)
48 - (NSString *)stringEscapedAsURI {
49 CFStringRef str = (__bridge CFStringRef)self;
50 CFStringRef str2 = (__bridge CFStringRef)(self);
55 @implementation NSString
58 return (__bridge id)(sref);
60 return (__bridge id)(strS->sref_member);
62 -(id)newString { return 0; }
65 extern void consumeParam(CFStringRef CF_CONSUMED p);
67 void f2(NSString *s) {
68 CFStringRef ref = (__bridge CFStringRef)([s string]);
69 ref = (__bridge CFStringRef)[s string];
70 ref = (__bridge CFStringRef)(s.string);
71 ref = CFBridgingRetain([NSString new]);
72 ref = CFBridgingRetain([s newString]);
73 ref = (CFStringRef)CFBridgingRetain([NSString new]);
74 ref = CFBridgingRetain([[NSString alloc] init]);
75 ref = CFBridgingRetain([s string]);
76 ref = (CFStringRef)CFBridgingRetain([s string]);
77 ref = CFBridgingRetain([s string]);
78 ref = CFBridgingRetain(s);
79 ref = CFBridgingRetain(s);
81 consumeParam((CFStringRef)CFBridgingRetain(s));
82 consumeParam(CFBridgingRetain(s));