summaryrefslogtreecommitdiff
path: root/test/ARCMT/nonobjc-to-objc-cast-2.m
diff options
context:
space:
mode:
Diffstat (limited to 'test/ARCMT/nonobjc-to-objc-cast-2.m')
-rw-r--r--test/ARCMT/nonobjc-to-objc-cast-2.m31
1 files changed, 26 insertions, 5 deletions
diff --git a/test/ARCMT/nonobjc-to-objc-cast-2.m b/test/ARCMT/nonobjc-to-objc-cast-2.m
index 1ec0089f08e8..80d694e58680 100644
--- a/test/ARCMT/nonobjc-to-objc-cast-2.m
+++ b/test/ARCMT/nonobjc-to-objc-cast-2.m
@@ -3,16 +3,37 @@
#include "Common.h"
-@interface NSString : NSObject
--(id)string;
--(id)newString;
-@end
-
typedef const struct __CFString * CFStringRef;
typedef const void * CFTypeRef;
CFTypeRef CFBridgingRetain(id X);
id CFBridgingRelease(CFTypeRef);
+struct StrS {
+ CFStringRef sref_member;
+};
+
+@interface NSString : NSObject {
+ CFStringRef sref;
+ struct StrS *strS;
+}
+-(id)string;
+-(id)newString;
+@end
+
+@implementation NSString
+-(id)string {
+ if (0)
+ return sref;
+ else
+ return strS->sref_member;
+}
+-(id)newString {
+ return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note{{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+}
+@end
+
void f(BOOL b) {
CFStringRef cfstr;
NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \