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,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}} 5*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1; 6*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge_related(NSColor,,))) CGColor2 *CGColorRef2; 7*0a6a1f1dSLionel Sambuc 8*0a6a1f1dSLionel Sambuc@interface NSColor // expected-note 5 {{declared here}} 9*0a6a1f1dSLionel Sambuc+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor; 10*0a6a1f1dSLionel Sambuc- (CGColorRef)CGColor; 11*0a6a1f1dSLionel Sambuc- (CGColorRef1)CGColor1; 12*0a6a1f1dSLionel Sambuc@end 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuc@interface NSTextField 15*0a6a1f1dSLionel Sambuc- (void)setBackgroundColor:(NSColor *)color; 16*0a6a1f1dSLionel Sambuc- (NSColor *)backgroundColor; 17*0a6a1f1dSLionel Sambuc@end 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambucvoid foo(NSColor*); // expected-note {{passing argument to parameter here}} 20*0a6a1f1dSLionel Sambuc 21*0a6a1f1dSLionel SambucNSColor * Test1(NSTextField *textField, CGColorRef newColor) { 22*0a6a1f1dSLionel Sambuc foo(newColor); // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 23*0a6a1f1dSLionel Sambuc textField.backgroundColor = newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 24*0a6a1f1dSLionel Sambuc return newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 25*0a6a1f1dSLionel Sambuc} 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel SambucNSColor * Test2(NSTextField *textField, CGColorRef1 newColor) { 28*0a6a1f1dSLionel Sambuc foo(newColor); // expected-warning {{incompatible pointer types passing 'CGColorRef1'}} 29*0a6a1f1dSLionel Sambuc textField.backgroundColor = newColor; // expected-warning {{incompatible pointer types assigning}} 30*0a6a1f1dSLionel Sambuc return newColor; // expected-warning {{incompatible pointer types returning}} 31*0a6a1f1dSLionel Sambuc} 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel SambucCGColorRef Test3(NSTextField *textField, CGColorRef newColor) { 34*0a6a1f1dSLionel Sambuc newColor = textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} 35*0a6a1f1dSLionel Sambuc return textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} 36*0a6a1f1dSLionel Sambuc} 37*0a6a1f1dSLionel Sambuc 38*0a6a1f1dSLionel SambucCGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) { 39*0a6a1f1dSLionel Sambuc newColor = textField.backgroundColor; // expected-warning {{incompatible pointer types assigning}} 40*0a6a1f1dSLionel Sambuc return textField.backgroundColor; // expected-warning {{incompatible pointer types returning}} 41*0a6a1f1dSLionel Sambuc} 42