blob: 66f56cfed4eafdc41223e8239f059a54bccf5009 [file] [log] [blame]
Fariborz Jahanian1f0b3bf2013-12-07 00:34:23 +00001// RUN: %clang_cc1 -fsyntax-only -x objective-c -verify -Wno-objc-root-class %s
2// rdar://15499111
3
4typedef struct __attribute__((objc_bridge_related(NSColor,colorXWithCGColor:,CXGColor))) CGColor *CGColorRef; // expected-note 2 {{declared here}}
5
6typedef struct __attribute__((objc_bridge_related(XNSColor,colorWithCGColor:,CGColor))) CGColor1 *CGColorRef1; // expected-note 2 {{declared here}}
7
8typedef struct __attribute__((objc_bridge_related(PNsColor,colorWithCGColor:,CGColor))) CGColor2 *CGColorRef2; // expected-note 2 {{declared here}}
9
10@interface NSColor
11+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor;
12- (CGColorRef)CGColor;
13@end
14
15@interface NSTextField
16- (void)setBackgroundColor:(NSColor *)color;
17- (NSColor *)backgroundColor;
18@end
19
20typedef int PNsColor; // expected-note 2 {{declared here}}
21
22NSColor * Test1(NSTextField *textField, CGColorRef newColor) {
23 textField.backgroundColor = newColor; // expected-error {{class method 'colorXWithCGColor:' for conversion of CF type 'CGColorRef' (aka 'struct CGColor *') to an ObjectiveC object of type 'NSColor *' not found}} \
24 // expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef' (aka 'struct CGColor *')}}
25 newColor = textField.backgroundColor; // expected-error {{instance method 'CXGColor' for conversion of an ObjectiveC type 'NSColor *' to a CF object of type 'CGColorRef' (aka 'struct CGColor *') not found}} \
26 // expected-warning {{incompatible pointer types assigning to 'CGColorRef' (aka 'struct CGColor *') from 'NSColor *'}}
27}
28NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
29 textField.backgroundColor = newColor; // expected-error {{could not find ObjectiveC class 'XNSColor' to convert 'CGColorRef1' (aka 'struct CGColor1 *') to 'NSColor *'}} \
30 // expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef1' (aka 'struct CGColor1 *')}}
31 newColor = textField.backgroundColor ; // expected-error {{could not find ObjectiveC class 'XNSColor' to convert 'NSColor *' to 'CGColorRef1' (aka 'struct CGColor1 *')}} \
32 // expected-warning {{incompatible pointer types assigning to 'CGColorRef1' (aka 'struct CGColor1 *') from 'NSColor *'}}
33}
34
35NSColor * Test3(NSTextField *textField, CGColorRef2 newColor) {
36 textField.backgroundColor = newColor; // expected-error {{'PNsColor' must be name of an ObjectiveC class to be able to convert 'CGColorRef2' (aka 'struct CGColor2 *') to 'NSColor *'}} \
37 // expected-warning {{incompatible pointer types assigning to 'NSColor *' from 'CGColorRef2' (aka 'struct CGColor2 *')}}
38 newColor = textField.backgroundColor; // expected-error {{'PNsColor' must be name of an ObjectiveC class to be able to convert 'NSColor *' to 'CGColorRef2' (aka 'struct CGColor2 *')}} \
39 // expected-warning {{incompatible pointer types assigning to 'CGColorRef2' (aka 'struct CGColor2 *') from 'NSColor *'}}
40}
41