blob: 59daef1ce64ba2d0ede1f2e9b63c645604e66a0a [file] [log] [blame]
Fariborz Jahanian67379e22013-12-09 22:04:26 +00001// RUN: %clang_cc1 -fsyntax-only -x objective-c -fobjc-arc -verify -Wno-objc-root-class %s
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +00002// rdar://15499111
3
4typedef struct __attribute__((objc_bridge_related(NSColor,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}}
Fariborz Jahanian381edf52013-12-16 22:54:37 +00005typedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1;
6typedef struct __attribute__((objc_bridge_related(NSColor,,))) CGColor2 *CGColorRef2;
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +00007
Fariborz Jahanian381edf52013-12-16 22:54:37 +00008@interface NSColor // expected-note 5 {{declared here}}
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +00009+ (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
Fariborz Jahanian381edf52013-12-16 22:54:37 +000019void foo(NSColor*); // expected-note {{passing argument to parameter here}}
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +000020
21NSColor * Test1(NSTextField *textField, CGColorRef newColor) {
Fariborz Jahanian67379e22013-12-09 22:04:26 +000022 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 *__strong'; 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 Jahanian1f0b3bf2013-12-07 00:34:23 +000025}
26
27NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
Fariborz Jahanian381edf52013-12-16 22:54:37 +000028 foo(newColor); // expected-warning {{incompatible pointer types passing 'CGColorRef1' (aka 'struct CGColor1 *') to parameter of type 'NSColor *'}}
29 textField.backgroundColor = newColor; // expected-warning {{incompatible pointer types assigning to 'NSColor *__strong' from 'CGColorRef1' (aka 'struct CGColor1 *')}}
30 return newColor; // expected-warning {{incompatible pointer types returning 'CGColorRef1' (aka 'struct CGColor1 *') from a function with result type 'NSColor *'}}
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +000031}
32
33CGColorRef Test3(NSTextField *textField, CGColorRef newColor) {
Fariborz Jahanian67379e22013-12-09 22:04:26 +000034 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 Jahanian1f0b3bf2013-12-07 00:34:23 +000036}
37
38CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) {
Fariborz Jahanian381edf52013-12-16 22:54:37 +000039 newColor = textField.backgroundColor; // expected-warning {{incompatible pointer types assigning}}
40 return textField.backgroundColor; // expected-warning {{incompatible pointer types returning}}
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +000041}