| 1 |
// RUN: %clang_cc1 -fsyntax-only -x objective-c -fobjc-arc -verify -Wno-objc-root-class %s |
| 2 |
|
| 3 |
typedef struct __attribute__((objc_bridge_related(NSColor,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}} |
| 4 |
typedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1; |
| 5 |
typedef 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 |
|
| 18 |
void foo(NSColor*); // expected-note {{passing argument to parameter here}} |
| 19 |
|
| 20 |
NSColor * 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 *__strong'; 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 |
|
| 26 |
NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) { |
| 27 |
foo(newColor); // expected-error {{incompatible pointer types passing 'CGColorRef1' (aka 'struct CGColor1 *') to parameter of type 'NSColor *'}} |
| 28 |
textField.backgroundColor = newColor; // expected-error {{incompatible pointer types assigning to 'NSColor *__strong' from 'CGColorRef1' (aka 'struct CGColor1 *')}} |
| 29 |
return newColor; // expected-error {{incompatible pointer types returning 'CGColorRef1' (aka 'struct CGColor1 *') from a function with result type 'NSColor *'}} |
| 30 |
} |
| 31 |
|
| 32 |
CGColorRef 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 |
|
| 37 |
CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) { |
| 38 |
newColor = textField.backgroundColor; // expected-error {{incompatible pointer types assigning}} |
| 39 |
return textField.backgroundColor; // expected-error {{incompatible pointer types returning}} |
| 40 |
} |