annotate clang/test/SemaObjC/method-direct-arc.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 -fobjc-arc -fsyntax-only -verify -Wselector-type-mismatch %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 extern Class object_getClass(id);
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 __attribute__((objc_root_class))
anatofuz
parents:
diff changeset
6 @interface Root
anatofuz
parents:
diff changeset
7 - (Class)class;
anatofuz
parents:
diff changeset
8 + (void)directMethod __attribute__((objc_direct)); // expected-note {{direct method 'directMethod' declared here}}
anatofuz
parents:
diff changeset
9 + (void)anotherDirectMethod __attribute__((objc_direct));
anatofuz
parents:
diff changeset
10 @end
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 @implementation Root
anatofuz
parents:
diff changeset
13 - (Class)class
anatofuz
parents:
diff changeset
14 {
anatofuz
parents:
diff changeset
15 return object_getClass(self);
anatofuz
parents:
diff changeset
16 }
anatofuz
parents:
diff changeset
17 + (void)directMethod {
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19 + (void)anotherDirectMethod {
anatofuz
parents:
diff changeset
20 [self directMethod]; // this should not warn
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22 + (void)regularMethod {
anatofuz
parents:
diff changeset
23 [self directMethod]; // this should not warn
anatofuz
parents:
diff changeset
24 [self anotherDirectMethod]; // this should not warn
anatofuz
parents:
diff changeset
25 }
anatofuz
parents:
diff changeset
26 - (void)regularInstanceMethod {
anatofuz
parents:
diff changeset
27 [[self class] directMethod]; // expected-error {{messaging a Class with a method that is possibly direct}}
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29 @end
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 @interface Sub : Root
anatofuz
parents:
diff changeset
32 @end
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 @implementation Sub
anatofuz
parents:
diff changeset
35 + (void)foo {
anatofuz
parents:
diff changeset
36 [self directMethod]; // this should not warn
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38 @end
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 __attribute__((objc_root_class))
anatofuz
parents:
diff changeset
41 @interface Other
anatofuz
parents:
diff changeset
42 @end
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 @implementation Other
anatofuz
parents:
diff changeset
45 + (void)bar {
anatofuz
parents:
diff changeset
46 [self directMethod]; // expected-error {{no known class method for selector 'directMethod'}}
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48 @end