2013-11-16 06:18:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
|
2013-11-14 07:59:17 +08:00
|
|
|
// rdar://15454846
|
|
|
|
|
2013-11-17 03:16:32 +08:00
|
|
|
typedef struct __CFErrorRef * __attribute__ ((objc_bridge(NSError))) CFErrorRef; // expected-note {{declared here}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-14 08:43:05 +08:00
|
|
|
typedef struct __CFMyColor * __attribute__((objc_bridge(12))) CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-14 08:43:05 +08:00
|
|
|
typedef struct __CFArray * __attribute__ ((objc_bridge)) CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-16 07:14:45 +08:00
|
|
|
typedef void * __attribute__ ((objc_bridge(NSURL))) CFURLRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-16 07:14:45 +08:00
|
|
|
typedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-14 09:00:26 +08:00
|
|
|
typedef struct __CFLocale * __attribute__((objc_bridge(NSLocale, NSError))) CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-16 07:14:45 +08:00
|
|
|
typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-14 09:00:26 +08:00
|
|
|
typedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-14 09:00:26 +08:00
|
|
|
typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet)));
|
2013-11-14 07:59:17 +08:00
|
|
|
|
2013-11-16 07:14:45 +08:00
|
|
|
typedef union __CFUColor * __attribute__((objc_bridge(NSUColor))) CFUColorRef; // expected-error {{'objc_bridge' attribute must be applied to a pointer to struct type}}
|
2013-11-14 07:59:17 +08:00
|
|
|
|
|
|
|
@interface I
|
|
|
|
{
|
|
|
|
__attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute must be put on a typedef only}}
|
|
|
|
|
|
|
|
}
|
|
|
|
@end
|
2013-11-16 06:18:17 +08:00
|
|
|
|
|
|
|
@protocol NSTesting @end
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
typedef struct __CFError * __attribute__((objc_bridge(NSTesting))) CFTestingRef; // expected-note {{declared here}}
|
|
|
|
|
2013-11-16 06:33:12 +08:00
|
|
|
id Test1(CFTestingRef cf) {
|
2013-11-16 07:14:45 +08:00
|
|
|
return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') is bridged to 'NSTesting', which is not an Objective-C class}}
|
2013-11-16 06:18:17 +08:00
|
|
|
}
|
2013-11-16 06:33:12 +08:00
|
|
|
|
|
|
|
typedef CFErrorRef CFErrorRef1;
|
|
|
|
|
|
|
|
typedef CFErrorRef1 CFErrorRef2;
|
|
|
|
|
|
|
|
@interface NSError @end
|
|
|
|
|
|
|
|
@interface MyError : NSError
|
|
|
|
@end
|
|
|
|
|
|
|
|
@class NSString;
|
|
|
|
|
2013-11-17 03:16:32 +08:00
|
|
|
void Test2(CFErrorRef2 cf, NSError *ns, NSString *str) {
|
2013-11-16 09:45:25 +08:00
|
|
|
(void)(NSString *)cf; // expected-warning {{CFErrorRef bridges to NSError, not NSString}}
|
|
|
|
(void)(NSError *)cf; // okay
|
|
|
|
(void)(MyError*)cf; // okay,
|
2013-11-17 03:16:32 +08:00
|
|
|
(void)(CFErrorRef)ns; // okay
|
|
|
|
(void)(CFErrorRef)str; // expected-warning {{NSString cannot bridge to CFErrorRef}}
|
2013-11-16 06:33:12 +08:00
|
|
|
}
|