1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc@protocol P0 4*f4a2713aSLionel Sambuc@end 5*f4a2713aSLionel Sambuc@protocol P1 6*f4a2713aSLionel Sambuc@end 7*f4a2713aSLionel Sambuc@protocol P2 8*f4a2713aSLionel Sambuc@end 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc@interface A <P0> 11*f4a2713aSLionel Sambuc@end 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc@interface B : A 14*f4a2713aSLionel Sambuc@end 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambucvoid bar(id x); 17*f4a2713aSLionel Sambucvoid barP0(id<P0> x); 18*f4a2713aSLionel Sambucvoid barP1(id<P1> x); 19*f4a2713aSLionel Sambucvoid barP2(id<P2> x); 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambucvoid f0(A *a) { 22*f4a2713aSLionel Sambuc id l = a; 23*f4a2713aSLionel Sambuc} 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambucvoid f1(id x, A *a) { 26*f4a2713aSLionel Sambuc id<P0> l = a; 27*f4a2713aSLionel Sambuc} 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambucvoid f2(id<P1> x) { 30*f4a2713aSLionel Sambuc id<P0> l = x; // expected-warning {{initializing 'id<P0>' with an expression of incompatible type 'id<P1>'}} 31*f4a2713aSLionel Sambuc} 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambucvoid f3(A *a) { 34*f4a2713aSLionel Sambuc id<P1> l = a; // expected-warning {{initializing 'id<P1>' with an expression of incompatible type 'A *'}} 35*f4a2713aSLionel Sambuc} 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambucvoid f4(int cond, id x, A *a) { 38*f4a2713aSLionel Sambuc bar(cond ? x : a); 39*f4a2713aSLionel Sambuc} 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambucvoid f5(int cond, A *a, B *b) { 42*f4a2713aSLionel Sambuc bar(cond ? a : b); 43*f4a2713aSLionel Sambuc} 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambucvoid f6(int cond, id x, A *a) { 46*f4a2713aSLionel Sambuc bar(cond ? (id<P0, P1>) x : a); 47*f4a2713aSLionel Sambuc} 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambucvoid f7(int cond, id x, A *a) { 50*f4a2713aSLionel Sambuc bar(cond ? a : (id<P0, P1>) x); 51*f4a2713aSLionel Sambuc} 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambucvoid f8(int cond, id<P0,P1> x0, id<P0,P2> x1) { 54*f4a2713aSLionel Sambuc barP0(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}} 55*f4a2713aSLionel Sambuc} 56*f4a2713aSLionel Sambuc 57*f4a2713aSLionel Sambucvoid f9(int cond, id<P0,P1> x0, id<P0,P2> x1) { 58*f4a2713aSLionel Sambuc barP1(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}} 59*f4a2713aSLionel Sambuc} 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambucvoid f10(int cond, id<P0,P1> x0, id<P0,P2> x1) { 62*f4a2713aSLionel Sambuc barP2(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}} 63*f4a2713aSLionel Sambuc} 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambucint f11(int cond, A* a, B* b) { 66*f4a2713aSLionel Sambuc return (cond? b : a)->x; // expected-error{{'A' does not have a member named 'x'}} 67*f4a2713aSLionel Sambuc} 68