Fariborz Jahanian | 1f0b3bf | 2013-12-07 00:34:23 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -x objective-c -verify -Wno-objc-root-class %s |
| 2 | // rdar://15499111 |
| 3 | |
| 4 | typedef struct __attribute__((objc_bridge_related(NSColor,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}} |
| 5 | typedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1; // expected-note 3 {{declared here}} |
| 6 | typedef struct __attribute__((objc_bridge_related(NSColor,,))) CGColor2 *CGColorRef2; // expected-note 2 {{declared here}} |
| 7 | |
| 8 | @interface NSColor // expected-note 10 {{declared here}} |
| 9 | + (NSColor *)colorWithCGColor:(CGColorRef)cgColor; |
| 10 | - (CGColorRef)CGColor; |
| 11 | - (CGColorRef1)CGColor1; |
| 12 | @end |
| 13 | |
| 14 | @interface NSTextField |
| 15 | - (void)setBackgroundColor:(NSColor *)color; |
| 16 | - (NSColor *)backgroundColor; |
| 17 | @end |
| 18 | |
| 19 | void foo(NSColor*); |
| 20 | |
| 21 | NSColor * Test1(NSTextField *textField, CGColorRef newColor) { |
Fariborz Jahanian | 67379e2 | 2013-12-09 22:04:26 +0000 | [diff] [blame^] | 22 | foo(newColor); // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} |
| 23 | textField.backgroundColor = newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} |
| 24 | return newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}} |
Fariborz Jahanian | 1f0b3bf | 2013-12-07 00:34:23 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) { |
Fariborz Jahanian | 67379e2 | 2013-12-09 22:04:26 +0000 | [diff] [blame^] | 28 | foo(newColor); // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}} |
| 29 | textField.backgroundColor = newColor; // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}} |
| 30 | return newColor; // expected-error {{you can't convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *', without using an existing class method for this conversion}} |
Fariborz Jahanian | 1f0b3bf | 2013-12-07 00:34:23 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | CGColorRef Test3(NSTextField *textField, CGColorRef newColor) { |
Fariborz Jahanian | 67379e2 | 2013-12-09 22:04:26 +0000 | [diff] [blame^] | 34 | newColor = textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} |
| 35 | return textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}} |
Fariborz Jahanian | 1f0b3bf | 2013-12-07 00:34:23 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) { |
Fariborz Jahanian | 67379e2 | 2013-12-09 22:04:26 +0000 | [diff] [blame^] | 39 | newColor = textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}} |
| 40 | return textField.backgroundColor; // expected-error {{you can't convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *'), without using an existing instance method for this conversion}} |
Fariborz Jahanian | 1f0b3bf | 2013-12-07 00:34:23 +0000 | [diff] [blame] | 41 | } |