1// RUN: %clang_cc1 -fsyntax-only -x objective-c -verify -Wno-objc-root-class %s 2 3typedef struct __attribute__((objc_bridge_related(NSColor,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}} 4typedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1; 5typedef struct __attribute__((objc_bridge_related(NSColor,,))) CGColor2 *CGColorRef2; 6 7@interface NSColor // expected-note 5 {{declared here}} 8+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor; 9- (CGColorRef)CGColor; 10- (CGColorRef1)CGColor1; 11@end 12 13@interface NSTextField 14- (void)setBackgroundColor:(NSColor *)color; 15- (NSColor *)backgroundColor; 16@end 17 18void foo(NSColor*); // expected-note {{passing argument to parameter here}} 19 20NSColor * Test1(NSTextField *textField, CGColorRef newColor) { 21 foo(newColor); // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 22 textField.backgroundColor = newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 23 return newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} 24} 25 26NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) { 27 foo(newColor); // expected-warning {{incompatible pointer types passing 'CGColorRef1'}} 28 textField.backgroundColor = newColor; // expected-warning {{incompatible pointer types assigning}} 29 return newColor; // expected-warning {{incompatible pointer types returning}} 30} 31 32CGColorRef Test3(NSTextField *textField, CGColorRef newColor) { 33 newColor = textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} 34 return textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} 35} 36 37CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) { 38 newColor = textField.backgroundColor; // expected-warning {{incompatible pointer types assigning}} 39 return textField.backgroundColor; // expected-warning {{incompatible pointer types returning}} 40} 41