Fariborz Jahanian | 87c7791 | 2013-11-21 20:50:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 | // rdar://15498044 |
| 3 | |
| 4 | typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary))) __CFDictionary * CFMutableDictionaryRef; // expected-note {{declared here}} |
| 5 | |
Fariborz Jahanian | 2651ac5 | 2013-11-22 00:02:22 +0000 | [diff] [blame] | 6 | typedef struct __attribute__((objc_bridge_mutable(12))) __CFDictionaryB1 * CFMutableDictionaryB1Ref; // expected-error {{parameter of 'objc_bridge_mutable' attribute must be a single name of an Objective-C class}} |
| 7 | |
| 8 | typedef struct __attribute__((objc_bridge_mutable(P))) __CFDictionaryB2 * CFMutableDictionaryB2Ref; // expected-note {{declared here}} |
| 9 | |
| 10 | typedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary, Unknown))) __CFDictionaryB3 * CFMutableDictionaryB3Ref; // expected-error {{use of undeclared identifier 'Unknown'}} |
| 11 | |
| 12 | typedef struct __attribute__((objc_bridge_mutable)) __CFDictionaryB4 * CFMutableDictionaryB4Ref; // expected-error {{'objc_bridge_mutable' attribute takes one argument}} |
| 13 | |
Fariborz Jahanian | 87c7791 | 2013-11-21 20:50:32 +0000 | [diff] [blame] | 14 | @interface NSDictionary |
| 15 | @end |
| 16 | |
| 17 | @interface NSMutableDictionary : NSDictionary |
| 18 | @end |
| 19 | |
Fariborz Jahanian | 2651ac5 | 2013-11-22 00:02:22 +0000 | [diff] [blame] | 20 | @protocol P @end |
| 21 | |
| 22 | void Test(NSMutableDictionary *md, NSDictionary *nd, CFMutableDictionaryRef mcf, CFMutableDictionaryB2Ref bmcf) { |
Fariborz Jahanian | 87c7791 | 2013-11-21 20:50:32 +0000 | [diff] [blame] | 23 | |
| 24 | (void) (CFMutableDictionaryRef)md; |
| 25 | (void) (CFMutableDictionaryRef)nd; // expected-warning {{'NSDictionary' cannot bridge to 'CFMutableDictionaryRef' (aka 'struct __CFDictionary *')}} |
Fariborz Jahanian | 27aa9b4 | 2015-04-10 22:07:47 +0000 | [diff] [blame] | 26 | (void) (NSDictionary *)mcf; // ok, bridgt_type NSMutableDictionary can be type-cast to its super class. |
| 27 | NSDictionary *nsdobj = (NSMutableDictionary*)0; |
Fariborz Jahanian | 87c7791 | 2013-11-21 20:50:32 +0000 | [diff] [blame] | 28 | (void) (NSMutableDictionary *)mcf; // ok; |
Fariborz Jahanian | 2651ac5 | 2013-11-22 00:02:22 +0000 | [diff] [blame] | 29 | (void) (NSMutableDictionary *)bmcf; // expected-error {{CF object of type 'CFMutableDictionaryB2Ref' (aka 'struct __CFDictionaryB2 *') is bridged to 'P', which is not an Objective-C class}} |
| 30 | |
Fariborz Jahanian | 87c7791 | 2013-11-21 20:50:32 +0000 | [diff] [blame] | 31 | } |
| 32 | |