xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/protocol-id-test-3.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -pedantic -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@protocol MyProto1
4*f4a2713aSLionel Sambuc@end
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@protocol MyProto2
7*f4a2713aSLionel Sambuc@end
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc@interface INTF @end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambucid<MyProto1> Func(INTF <MyProto1, MyProto2> *p2) // expected-note 2{{passing argument to parameter 'p2' here}}
12*f4a2713aSLionel Sambuc{
13*f4a2713aSLionel Sambuc	return p2;
14*f4a2713aSLionel Sambuc}
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc id<MyProto1> Gunc(id <MyProto1, MyProto2>p2)
20*f4a2713aSLionel Sambuc{
21*f4a2713aSLionel Sambuc	return p2;
22*f4a2713aSLionel Sambuc}
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuc id<MyProto1> Gunc1(id <MyProto1, MyProto2>p2)
26*f4a2713aSLionel Sambuc{
27*f4a2713aSLionel Sambuc	return p2;
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambucid<MyProto1, MyProto2> Gunc2(id <MyProto1>p2)
31*f4a2713aSLionel Sambuc{
32*f4a2713aSLionel Sambuc	Func(p2);	// expected-warning {{passing 'id<MyProto1>' to parameter of incompatible type 'INTF<MyProto1,MyProto2> *'}}
33*f4a2713aSLionel Sambuc	return p2;	// expected-warning {{returning 'id<MyProto1>' from a function with incompatible result type 'id<MyProto1,MyProto2>'}}
34*f4a2713aSLionel Sambuc}
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambucid<MyProto1> Gunc3(id <MyProto2>p2)
39*f4a2713aSLionel Sambuc{
40*f4a2713aSLionel Sambuc	return p2;	 // expected-warning {{returning 'id<MyProto2>' from a function with incompatible result type 'id<MyProto1>'}}
41*f4a2713aSLionel Sambuc}
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambucid<MyProto1, MyProto2> Gunc4(id <MyProto2, MyProto1>p2)
45*f4a2713aSLionel Sambuc{
46*f4a2713aSLionel Sambuc	return p2;
47*f4a2713aSLionel Sambuc}
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel SambucINTF<MyProto1> * Hunc(id <MyProto1, MyProto2>p2)
52*f4a2713aSLionel Sambuc{
53*f4a2713aSLionel Sambuc	return p2;
54*f4a2713aSLionel Sambuc}
55*f4a2713aSLionel Sambuc
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel SambucINTF<MyProto1> * Hunc1(id <MyProto1, MyProto2>p2)
58*f4a2713aSLionel Sambuc{
59*f4a2713aSLionel Sambuc	return p2;
60*f4a2713aSLionel Sambuc}
61*f4a2713aSLionel Sambuc
62*f4a2713aSLionel SambucINTF<MyProto1, MyProto2> * Hunc2(id <MyProto1>p2)
63*f4a2713aSLionel Sambuc{
64*f4a2713aSLionel Sambuc	Func(p2);	// expected-warning {{passing 'id<MyProto1>' to parameter of incompatible type 'INTF<MyProto1,MyProto2> *'}}
65*f4a2713aSLionel Sambuc	return p2;	// expected-warning {{returning 'id<MyProto1>' from a function with incompatible result type 'INTF<MyProto1,MyProto2> *'}}
66*f4a2713aSLionel Sambuc}
67*f4a2713aSLionel Sambuc
68*f4a2713aSLionel SambucINTF<MyProto1> * Hunc3(id <MyProto2>p2)
69*f4a2713aSLionel Sambuc{
70*f4a2713aSLionel Sambuc	return p2;	 // expected-warning {{returning 'id<MyProto2>' from a function with incompatible result type 'INTF<MyProto1> *'}}
71*f4a2713aSLionel Sambuc}
72*f4a2713aSLionel Sambuc
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel SambucINTF<MyProto1, MyProto2> * Hunc4(id <MyProto2, MyProto1>p2)
75*f4a2713aSLionel Sambuc{
76*f4a2713aSLionel Sambuc	return p2;
77*f4a2713aSLionel Sambuc}
78*f4a2713aSLionel Sambuc
79*f4a2713aSLionel Sambucid Iunc(id <MyProto1, MyProto2>p2)
80*f4a2713aSLionel Sambuc{
81*f4a2713aSLionel Sambuc	return p2;
82*f4a2713aSLionel Sambuc}
83*f4a2713aSLionel Sambuc
84*f4a2713aSLionel Sambuc
85*f4a2713aSLionel Sambucid<MyProto1> Iunc1(id p2)
86*f4a2713aSLionel Sambuc{
87*f4a2713aSLionel Sambuc	return p2;
88*f4a2713aSLionel Sambuc}
89*f4a2713aSLionel Sambuc
90*f4a2713aSLionel Sambucid<MyProto1, MyProto2> Iunc2(id p2)
91*f4a2713aSLionel Sambuc{
92*f4a2713aSLionel Sambuc	Iunc(p2);
93*f4a2713aSLionel Sambuc	return p2;
94*f4a2713aSLionel Sambuc}
95