blob: bb2d3e28515f324a8924b93592f5b9b4fc7d0c40 [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 Jahaniana0f03952013-11-14 01:00:26 +00004typedef struct __CFErrorRef * __attribute__ ((objc_bridge(NSError))) CFErrorRef;
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +00005
Fariborz Jahanianae02d152013-11-14 00:43:05 +00006typedef struct __CFMyColor * __attribute__((objc_bridge(12))) 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 Jahanianae02d152013-11-14 00:43:05 +00008typedef struct __CFArray * __attribute__ ((objc_bridge)) 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 Jahaniana0f03952013-11-14 01:00:26 +000010typedef void * __attribute__ ((objc_bridge(NSURL))) CFURLRef;
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000011
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000012typedef void * CFStringRef __attribute__ ((objc_bridge(NSString)));
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000013
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000014typedef struct __CFLocale * __attribute__((objc_bridge(NSLocale, NSError))) CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000015
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000016typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer type}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000017
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000018typedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000019
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000020typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet)));
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000021
Fariborz Jahaniana0f03952013-11-14 01:00:26 +000022typedef union __CFUColor * __attribute__((objc_bridge(NSUColor))) CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to structs}}
Fariborz Jahanian0a0a3972013-11-13 23:59:17 +000023
24@interface I
25{
26 __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
27
28}
29@end
Fariborz Jahaniana649c822013-11-15 22:18:17 +000030
31@protocol NSTesting @end
32@class NSString;
33
34typedef struct __CFError * __attribute__((objc_bridge(NSTesting))) CFTestingRef; // expected-note {{declared here}}
35
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000036id Test1(CFTestingRef cf) {
Fariborz Jahaniana649c822013-11-15 22:18:17 +000037 return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') with 'objc_bridge' attribute which has parameter that does not name an Objective-C class}}
38}
Fariborz Jahaniane79cef62013-11-15 22:33:12 +000039
40typedef CFErrorRef CFErrorRef1;
41
42typedef CFErrorRef1 CFErrorRef2;
43
44@interface NSError @end
45
46@interface MyError : NSError
47@end
48
49@class NSString;
50
51id Test2(CFErrorRef2 cf) {
52 return (NSString *)cf;
53}