annotate clang/test/SemaObjC/protocol-archane.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-pointer-to-int-cast -Wno-objc-root-class %s
150
anatofuz
parents:
diff changeset
2 // rdar://5986251
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 @protocol SomeProtocol
anatofuz
parents:
diff changeset
5 - (void) bar;
anatofuz
parents:
diff changeset
6 @end
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 void bar();
anatofuz
parents:
diff changeset
9 void foo(id x) {
anatofuz
parents:
diff changeset
10 bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
anatofuz
parents:
diff changeset
11 bar((<SomeProtocol>)x); // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 [(<SomeProtocol>)x bar]; // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 @protocol MyProtocol
anatofuz
parents:
diff changeset
17 - (void)doSomething;
anatofuz
parents:
diff changeset
18 @end
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 @interface MyClass
anatofuz
parents:
diff changeset
21 - (void)m1:(id <MyProtocol> const)arg1;
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 // FIXME: provide a better diagnostic (no typedef).
anatofuz
parents:
diff changeset
24 - (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
anatofuz
parents:
diff changeset
25 @end
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 typedef int NotAnObjCObjectType;
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 // GCC doesn't diagnose this.
anatofuz
parents:
diff changeset
30 NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 typedef struct objc_class *Class;
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 Class <SomeProtocol> UnfortunateGCCExtension;
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 // rdar://10238337
anatofuz
parents:
diff changeset
37 @protocol Broken @end
anatofuz
parents:
diff changeset
38 @interface Crash @end
anatofuz
parents:
diff changeset
39 @implementation Crash
anatofuz
parents:
diff changeset
40 - (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42 @end
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 typedef <SomeProtocol> id TwoTypeSpecs; // expected-warning{{no object type specified}}
anatofuz
parents:
diff changeset
45 // expected-error@-1{{typedef redefinition with different types ('id<SomeProtocol>' vs 'id')}}
anatofuz
parents:
diff changeset
46 // expected-error@-2{{expected ';' after top level declarator}}