annotate clang/test/SemaObjC/objcbridge-related-attribute.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -x objective-c -verify -Wno-objc-root-class %s
anatofuz
parents:
diff changeset
2 // rdar://15499111
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 typedef struct __attribute__((objc_bridge_related(NSColor,colorWithCGColor:,CGColor))) CGColor *CGColorRef; // expected-note 5 {{declared here}}
anatofuz
parents:
diff changeset
5 typedef struct __attribute__((objc_bridge_related(NSColor,,CGColor1))) CGColor1 *CGColorRef1;
anatofuz
parents:
diff changeset
6 typedef struct __attribute__((objc_bridge_related(NSColor,,))) CGColor2 *CGColorRef2;
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 @interface NSColor // expected-note 5 {{declared here}}
anatofuz
parents:
diff changeset
9 + (NSColor *)colorWithCGColor:(CGColorRef)cgColor;
anatofuz
parents:
diff changeset
10 - (CGColorRef)CGColor;
anatofuz
parents:
diff changeset
11 - (CGColorRef1)CGColor1;
anatofuz
parents:
diff changeset
12 @end
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 @interface NSTextField
anatofuz
parents:
diff changeset
15 - (void)setBackgroundColor:(NSColor *)color;
anatofuz
parents:
diff changeset
16 - (NSColor *)backgroundColor;
anatofuz
parents:
diff changeset
17 @end
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 void foo(NSColor*); // expected-note {{passing argument to parameter here}}
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 NSColor * Test1(NSTextField *textField, CGColorRef newColor) {
anatofuz
parents:
diff changeset
22 foo(newColor); // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}}
anatofuz
parents:
diff changeset
23 textField.backgroundColor = newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}}
anatofuz
parents:
diff changeset
24 return newColor; // expected-error {{'CGColorRef' (aka 'struct CGColor *') must be explicitly converted to 'NSColor *'; use '+colorWithCGColor:' method for this conversion}}
anatofuz
parents:
diff changeset
25 }
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 NSColor * Test2(NSTextField *textField, CGColorRef1 newColor) {
anatofuz
parents:
diff changeset
28 foo(newColor); // expected-warning {{incompatible pointer types passing 'CGColorRef1'}}
anatofuz
parents:
diff changeset
29 textField.backgroundColor = newColor; // expected-warning {{incompatible pointer types assigning}}
anatofuz
parents:
diff changeset
30 return newColor; // expected-warning {{incompatible pointer types returning}}
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 CGColorRef Test3(NSTextField *textField, CGColorRef newColor) {
anatofuz
parents:
diff changeset
34 newColor = textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}}
anatofuz
parents:
diff changeset
35 return textField.backgroundColor; // expected-error {{'NSColor *' must be explicitly converted to 'CGColorRef' (aka 'struct CGColor *'); use '-CGColor' method for this conversion}}
anatofuz
parents:
diff changeset
36 }
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 CGColorRef2 Test4(NSTextField *textField, CGColorRef2 newColor) {
anatofuz
parents:
diff changeset
39 newColor = textField.backgroundColor; // expected-warning {{incompatible pointer types assigning}}
anatofuz
parents:
diff changeset
40 return textField.backgroundColor; // expected-warning {{incompatible pointer types returning}}
anatofuz
parents:
diff changeset
41 }