xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/objcbridgemutable-attribute.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*0a6a1f1dSLionel Sambuc// rdar://15498044
3*0a6a1f1dSLionel Sambuc
4*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary))) __CFDictionary * CFMutableDictionaryRef; // expected-note {{declared here}}
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuctypedef 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*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_mutable(P))) __CFDictionaryB2 * CFMutableDictionaryB2Ref; // expected-note {{declared here}}
9*0a6a1f1dSLionel Sambuc
10*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_mutable(NSMutableDictionary, Unknown))) __CFDictionaryB3 * CFMutableDictionaryB3Ref;  // expected-error {{use of undeclared identifier 'Unknown'}}
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_mutable)) __CFDictionaryB4 * CFMutableDictionaryB4Ref;  // expected-error {{'objc_bridge_mutable' attribute takes one argument}}
13*0a6a1f1dSLionel Sambuc
14*0a6a1f1dSLionel Sambuc@interface NSDictionary
15*0a6a1f1dSLionel Sambuc@end
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc@interface NSMutableDictionary : NSDictionary
18*0a6a1f1dSLionel Sambuc@end
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc@protocol P @end
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel Sambucvoid Test(NSMutableDictionary *md, NSDictionary *nd, CFMutableDictionaryRef mcf, CFMutableDictionaryB2Ref bmcf) {
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc  (void) (CFMutableDictionaryRef)md;
25*0a6a1f1dSLionel Sambuc  (void) (CFMutableDictionaryRef)nd; // expected-warning {{'NSDictionary' cannot bridge to 'CFMutableDictionaryRef' (aka 'struct __CFDictionary *')}}
26*0a6a1f1dSLionel Sambuc  (void) (NSDictionary *)mcf;  // expected-warning {{'CFMutableDictionaryRef' (aka 'struct __CFDictionary *') bridges to NSMutableDictionary, not 'NSDictionary'}}
27*0a6a1f1dSLionel Sambuc  (void) (NSMutableDictionary *)mcf; // ok;
28*0a6a1f1dSLionel Sambuc  (void) (NSMutableDictionary *)bmcf; // expected-error {{CF object of type 'CFMutableDictionaryB2Ref' (aka 'struct __CFDictionaryB2 *') is bridged to 'P', which is not an Objective-C class}}
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc}
31*0a6a1f1dSLionel Sambuc
32