blob: 2db2ff4929e8df0e78e533519234a3abf017f0a0 [file] [log] [blame]
Fariborz Jahaniana649c822013-11-15 22:18:17 +00001// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +00002// rdar://15454846
3
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +00004typedef struct __attribute__ ((objc_bridge(NSError))) __CFErrorRef * CFErrorRef; // expected-note 2 {{declared here}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +00005
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +00006typedef struct __attribute__((objc_bridge(12))) __CFMyColor *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +00007
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +00008typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +00009
Fariborz Jahanianf720f862013-11-19 17:42:25 +000010typedef void * __attribute__ ((objc_bridge(NSURL))) CFURLRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000011
Fariborz Jahanianf720f862013-11-19 17:42:25 +000012typedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute only applies to struct or union}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000013
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000014typedef struct __attribute__((objc_bridge(NSLocale, NSError))) __CFLocale *CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000015
Fariborz Jahanianf720f862013-11-19 17:42:25 +000016typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000017
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000018typedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef;
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000019
Fariborz Jahanianf720f862013-11-19 17:42:25 +000020typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet))); // expected-error {{'objc_bridge' attribute only applies to struct or union}};
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000021
Fariborz Jahanianf720f862013-11-19 17:42:25 +000022typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}};
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000023
Fariborz Jahanianf720f862013-11-19 17:42:25 +000024typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{'objc_bridge' attribute only applies to struct or union}};
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000025
26typedef union __attribute__((objc_bridge(NSUColor))) __CFUPrimeColor XXX;
27typedef XXX *CFUColor2Ref;
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000028
29@interface I
30{
Fariborz Jahanianf720f862013-11-19 17:42:25 +000031 __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to struct or union}};
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000032}
33@end
Fariborz Jahaniana649c822013-11-15 22:18:17 +000034
35@protocol NSTesting @end
36@class NSString;
37
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000038typedef struct __attribute__((objc_bridge(NSTesting))) __CFError *CFTestingRef; // expected-note {{declared here}}
Fariborz Jahaniana649c822013-11-15 22:18:17 +000039
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000040id Test1(CFTestingRef cf) {
Fariborz Jahanianb8233192013-11-15 23:14:45 +000041 return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') is bridged to 'NSTesting', which is not an Objective-C class}}
Fariborz Jahaniana649c822013-11-15 22:18:17 +000042}
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000043
44typedef CFErrorRef CFErrorRef1;
45
46typedef CFErrorRef1 CFErrorRef2;
47
48@interface NSError @end
49
50@interface MyError : NSError
51@end
52
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000053@interface NSUColor @end
54
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000055@class NSString;
56
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000057void Test2(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) {
Fariborz Jahanian509f31e2013-11-19 01:23:07 +000058 (void)(NSString *)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'NSString'}}
Fariborz Jahanianf07183c2013-11-16 01:45:25 +000059 (void)(NSError *)cf; // okay
60 (void)(MyError*)cf; // okay,
Fariborz Jahaniandb3d8552013-11-19 00:09:48 +000061 (void)(NSUColor *)cf2; // okay
Fariborz Jahanian8a0210e2013-11-16 19:16:32 +000062 (void)(CFErrorRef)ns; // okay
Fariborz Jahanian509f31e2013-11-19 01:23:07 +000063 (void)(CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}}
64 (void)(Class)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'Class'}}
Fariborz Jahanian2c312122013-11-16 23:22:37 +000065 (void)(CFErrorRef)c; // expected-warning {{'Class' cannot bridge to 'CFErrorRef'}}
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000066}