xref: /aosp_15_r20/external/clang/test/SemaObjC/objc-mixed-bridge-attribute.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li// expected-no-diagnostics
3*67e74705SXin Li// rdar://17238954
4*67e74705SXin Li
5*67e74705SXin Litypedef const struct __attribute__((objc_bridge(NSAttributedString))) __CFAttributedString *CFAttributedStringRef;
6*67e74705SXin Li
7*67e74705SXin Litypedef struct __attribute__((objc_bridge_mutable(NSMutableAttributedString))) __CFAttributedString *CFMutableAttributedStringRef;
8*67e74705SXin Li
9*67e74705SXin Li@interface NSAttributedString
10*67e74705SXin Li@end
11*67e74705SXin Li
12*67e74705SXin Li@interface NSMutableAttributedString
13*67e74705SXin Li@end
14*67e74705SXin Li
15*67e74705SXin Listruct __CFAttributedString {
16*67e74705SXin Li};
17*67e74705SXin Li
18*67e74705SXin Livoid Test1(CFAttributedStringRef attrStr, CFMutableAttributedStringRef mutable_attrStr)
19*67e74705SXin Li{
20*67e74705SXin Li  id x = (NSAttributedString *) attrStr;
21*67e74705SXin Li  id x1 =(NSAttributedString *) mutable_attrStr;
22*67e74705SXin Li  id x2 = (NSMutableAttributedString *) attrStr;
23*67e74705SXin Li  id x3 = (NSMutableAttributedString *) mutable_attrStr;
24*67e74705SXin Li}
25*67e74705SXin Li
26*67e74705SXin Livoid Test2(NSAttributedString *ns_attrStr, NSMutableAttributedString *ns_mutable_attr_Str) {
27*67e74705SXin Li  CFAttributedStringRef cfsr = (CFAttributedStringRef) ns_attrStr;
28*67e74705SXin Li  CFMutableAttributedStringRef cfsr1 = (CFMutableAttributedStringRef) ns_attrStr;
29*67e74705SXin Li  CFAttributedStringRef cfsr2 = (CFAttributedStringRef) ns_mutable_attr_Str;
30*67e74705SXin Li  CFMutableAttributedStringRef cfsr3 = (CFMutableAttributedStringRef) ns_mutable_attr_Str;
31*67e74705SXin Li}
32*67e74705SXin Li
33*67e74705SXin Li// Tests with no definition declaration for struct __NDCFAttributedString.
34*67e74705SXin Litypedef const struct __attribute__((objc_bridge(NSAttributedString))) __NDCFAttributedString *NDCFAttributedStringRef;
35*67e74705SXin Li
36*67e74705SXin Litypedef struct __attribute__((objc_bridge_mutable(NSMutableAttributedString))) __NDCFAttributedString *NDCFMutableAttributedStringRef;
37*67e74705SXin Li
38*67e74705SXin Livoid Test3(NDCFAttributedStringRef attrStr, NDCFMutableAttributedStringRef mutable_attrStr)
39*67e74705SXin Li{
40*67e74705SXin Li  id x = (NSAttributedString *) attrStr;
41*67e74705SXin Li  id x1 =(NSAttributedString *) mutable_attrStr;
42*67e74705SXin Li  id x2 = (NSMutableAttributedString *) attrStr;
43*67e74705SXin Li  id x3 = (NSMutableAttributedString *) mutable_attrStr;
44*67e74705SXin Li}
45*67e74705SXin Li
46*67e74705SXin Livoid Test4(NSAttributedString *ns_attrStr, NSMutableAttributedString *ns_mutable_attr_Str) {
47*67e74705SXin Li  NDCFAttributedStringRef cfsr = (NDCFAttributedStringRef) ns_attrStr;
48*67e74705SXin Li  NDCFMutableAttributedStringRef cfsr1 = (NDCFMutableAttributedStringRef) ns_attrStr;
49*67e74705SXin Li  NDCFAttributedStringRef cfsr2 = (NDCFAttributedStringRef) ns_mutable_attr_Str;
50*67e74705SXin Li  NDCFMutableAttributedStringRef cfsr3 = (NDCFMutableAttributedStringRef) ns_mutable_attr_Str;
51*67e74705SXin Li}
52