annotate clang/test/SemaObjCXX/conditional-expr.mm @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +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 -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 @protocol P0
anatofuz
parents:
diff changeset
4 @end
anatofuz
parents:
diff changeset
5 @protocol P1
anatofuz
parents:
diff changeset
6 @end
anatofuz
parents:
diff changeset
7 @protocol P2
anatofuz
parents:
diff changeset
8 @end
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 @interface A <P0>
anatofuz
parents:
diff changeset
11 @end
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 @interface B : A
anatofuz
parents:
diff changeset
14 @end
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 void bar(id x);
anatofuz
parents:
diff changeset
17 void barP0(id<P0> x);
anatofuz
parents:
diff changeset
18 void barP1(id<P1> x);
anatofuz
parents:
diff changeset
19 void barP2(id<P2> x);
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 void f0(A *a) {
anatofuz
parents:
diff changeset
22 id l = a;
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 void f1(id x, A *a) {
anatofuz
parents:
diff changeset
26 id<P0> l = a;
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 void f2(id<P1> x) {
anatofuz
parents:
diff changeset
30 id<P0> l = x; // expected-error {{cannot initialize a variable of type 'id<P0>' with an lvalue of type 'id<P1>'}}
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 void f3(A *a) {
anatofuz
parents:
diff changeset
34 id<P1> l = a; // expected-error {{cannot initialize a variable of type 'id<P1>' with an lvalue of type 'A *'}}
anatofuz
parents:
diff changeset
35 }
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 void f4(int cond, id x, A *a) {
anatofuz
parents:
diff changeset
38 bar(cond ? x : a);
anatofuz
parents:
diff changeset
39 }
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 void f5(int cond, A *a, B *b) {
anatofuz
parents:
diff changeset
42 bar(cond ? a : b);
anatofuz
parents:
diff changeset
43 }
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 void f6(int cond, id x, A *a) {
anatofuz
parents:
diff changeset
46 bar(cond ? (id<P0, P1>) x : a);
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 void f7(int cond, id x, A *a) {
anatofuz
parents:
diff changeset
50 bar(cond ? a : (id<P0, P1>) x);
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 void f8(int cond, id<P0,P1> x0, id<P0,P2> x1) {
anatofuz
parents:
diff changeset
54 barP0(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
anatofuz
parents:
diff changeset
55 }
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 void f9(int cond, id<P0,P1> x0, id<P0,P2> x1) {
anatofuz
parents:
diff changeset
58 barP1(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 void f10(int cond, id<P0,P1> x0, id<P0,P2> x1) {
anatofuz
parents:
diff changeset
62 barP2(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
anatofuz
parents:
diff changeset
63 }
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 int f11(int cond, A* a, B* b) {
anatofuz
parents:
diff changeset
66 return (cond? b : a)->x; // expected-error{{'A' does not have a member named 'x'}}
anatofuz
parents:
diff changeset
67 }