1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc@interface A { 4*f4a2713aSLionel Sambuc@public 5*f4a2713aSLionel Sambuc int ivar; 6*f4a2713aSLionel Sambuc} 7*f4a2713aSLionel Sambuc@property int prop; 8*f4a2713aSLionel Sambuc@end 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuctypedef struct objc_object { 11*f4a2713aSLionel Sambuc Class isa; 12*f4a2713aSLionel Sambuc} *id; 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc// Test instantiation of value-dependent ObjCIvarRefExpr, 15*f4a2713aSLionel Sambuc// ObjCIsaRefExpr, and ObjCPropertyRefExpr nodes. 16*f4a2713aSLionel SambucA *get_an_A(unsigned); 17*f4a2713aSLionel Sambucid get_an_id(unsigned); 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuctemplate<unsigned N, typename T, typename U, typename V> 20*f4a2713aSLionel Sambucvoid f(U value, V value2) { 21*f4a2713aSLionel Sambuc get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} 22*f4a2713aSLionel Sambuc get_an_A(N).prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}} 23*f4a2713aSLionel Sambuc T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \ 24*f4a2713aSLionel Sambuc // expected-warning 3 {{direct access to Objective-C's isa is deprecated in favor of object_getClass()}} 25*f4a2713aSLionel Sambuc} 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuctemplate void f<6, Class>(int, int); // expected-note{{in instantiation of}} 28*f4a2713aSLionel Sambuctemplate void f<7, Class>(int*, int); // expected-note{{in instantiation of}} 29*f4a2713aSLionel Sambuctemplate void f<8, Class>(int, double*); // expected-note{{in instantiation of}} 30*f4a2713aSLionel Sambuctemplate void f<9, int>(int, int); // expected-note{{in instantiation of}} 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc// Test instantiation of unresolved member reference expressions to an 33*f4a2713aSLionel Sambuc// ivar reference. 34*f4a2713aSLionel Sambuctemplate<typename T, typename U, typename V> 35*f4a2713aSLionel Sambucvoid f2(T ptr, U value, V value2) { 36*f4a2713aSLionel Sambuc ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} 37*f4a2713aSLionel Sambuc ptr.prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}} 38*f4a2713aSLionel Sambuc} 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuctemplate void f2(A*, int, int); 41*f4a2713aSLionel Sambuctemplate void f2(A*, int*, int); // expected-note{{instantiation of}} 42*f4a2713aSLionel Sambuctemplate void f2(A*, int, double*); // expected-note{{instantiation of}} 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc// Test instantiation of unresolved member referfence expressions to 45*f4a2713aSLionel Sambuc// an isa. 46*f4a2713aSLionel Sambuctemplate<typename T, typename U> 47*f4a2713aSLionel Sambucvoid f3(U ptr) { 48*f4a2713aSLionel Sambuc T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \ 49*f4a2713aSLionel Sambuc // expected-warning 1 {{direct access to Objective-C's isa is deprecated in favor of object_getClass()}} 50*f4a2713aSLionel Sambuc} 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuctemplate void f3<Class>(id); // expected-note{{in instantiation of}} 53*f4a2713aSLionel Sambuctemplate void f3<int>(id); // expected-note{{instantiation of}} 54*f4a2713aSLionel Sambuc 55*f4a2713aSLionel Sambuc// Implicit setter/getter 56*f4a2713aSLionel Sambuc@interface B 57*f4a2713aSLionel Sambuc- (int)foo; 58*f4a2713aSLionel Sambuc- (void)setFoo:(int)value; 59*f4a2713aSLionel Sambuc@end 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuctemplate<typename T> 62*f4a2713aSLionel Sambucvoid f4(B *b, T value) { 63*f4a2713aSLionel Sambuc b.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} 64*f4a2713aSLionel Sambuc} 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuctemplate void f4(B*, int); 67*f4a2713aSLionel Sambuctemplate void f4(B*, int*); // expected-note{{in instantiation of function template specialization 'f4<int *>' requested here}} 68*f4a2713aSLionel Sambuc 69*f4a2713aSLionel Sambuctemplate<typename T, typename U> 70*f4a2713aSLionel Sambucvoid f5(T ptr, U value) { 71*f4a2713aSLionel Sambuc ptr.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} 72*f4a2713aSLionel Sambuc} 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambuctemplate void f5(B*, int); 75*f4a2713aSLionel Sambuctemplate void f5(B*, int*); // expected-note{{in instantiation of function template specialization 'f5<B *, int *>' requested here}} 76