xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/check-objcbridge-related-attribute-lookup.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -x objective-c -verify -Wno-objc-root-class %s
2*0a6a1f1dSLionel Sambuc// rdar://15499111
3*0a6a1f1dSLionel Sambuc
4*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_related(NSColor,colorXWithCGColor:,CXGColor))) CGColor *CGColorRef; // expected-note 2 {{declared here}}
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_related(XNSColor,colorWithCGColor:,CGColor))) CGColor1 *CGColorRef1; // expected-note 2 {{declared here}}
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_related(PNsColor,colorWithCGColor:,CGColor))) CGColor2 *CGColorRef2; // expected-note 2 {{declared here}}
9*0a6a1f1dSLionel Sambuc
10*0a6a1f1dSLionel Sambuc@interface NSColor
11*0a6a1f1dSLionel Sambuc+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor;
12*0a6a1f1dSLionel Sambuc- (CGColorRef)CGColor;
13*0a6a1f1dSLionel Sambuc@end
14*0a6a1f1dSLionel Sambuc
15*0a6a1f1dSLionel Sambuc@interface NSTextField
16*0a6a1f1dSLionel Sambuc- (void)setBackgroundColor:(NSColor *)color;
17*0a6a1f1dSLionel Sambuc- (NSColor *)backgroundColor;
18*0a6a1f1dSLionel Sambuc@end
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuctypedef int PNsColor; // expected-note 2 {{declared here}}
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel SambucNSColor * Test1(NSTextField *textField, CGColorRef newColor) {
23*0a6a1f1dSLionel Sambuc textField.backgroundColor = newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorXWithCGColor:' method for this conversion}} \
24*0a6a1f1dSLionel Sambuc					// expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef' (aka 'struct CGColor *')}}
25*0a6a1f1dSLionel Sambuc newColor = textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CXGColor' method for this conversion}} \
26*0a6a1f1dSLionel Sambuc					// expected-warning {{incompatible pointer types assigning to 'CGColorRef' (aka 'struct CGColor *') from 'NSColor *'}}
27*0a6a1f1dSLionel Sambuc}
28*0a6a1f1dSLionel SambucNSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
29*0a6a1f1dSLionel Sambuc textField.backgroundColor = newColor; // expected-error {{could not find Objective-C class 'XNSColor' to convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *'}} \
30*0a6a1f1dSLionel Sambuc				       // expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef1' (aka 'struct CGColor1 *')}}
31*0a6a1f1dSLionel Sambuc newColor = textField.backgroundColor ; // expected-error {{could not find Objective-C class 'XNSColor' to convert 'NSColor *' to 'CGColorRef1' (aka 'struct CGColor1 *')}} \
32*0a6a1f1dSLionel Sambuc					// expected-warning {{incompatible pointer types assigning to 'CGColorRef1' (aka 'struct CGColor1 *') from 'NSColor *'}}
33*0a6a1f1dSLionel Sambuc}
34*0a6a1f1dSLionel Sambuc
35*0a6a1f1dSLionel SambucNSColor * Test3(NSTextField *textField, CGColorRef2 newColor) {
36*0a6a1f1dSLionel Sambuc textField.backgroundColor = newColor; // expected-error {{'PNsColor' must be name of an Objective-C class to be able to convert 'CGColorRef2' (aka 'struct CGColor2 *') to 'NSColor *'}} \
37*0a6a1f1dSLionel Sambuc					// expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef2' (aka 'struct CGColor2 *')}}
38*0a6a1f1dSLionel Sambuc newColor = textField.backgroundColor; // expected-error {{'PNsColor' must be name of an Objective-C class to be able to convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *')}} \
39*0a6a1f1dSLionel Sambuc					// expected-warning {{incompatible pointer types assigning to 'CGColorRef2' (aka 'struct CGColor2 *') from 'NSColor *'}}
40*0a6a1f1dSLionel Sambuc}
41*0a6a1f1dSLionel Sambuc
42