Teach TreeTransform how to transform a pack expansion type into
[clang.git] / test / SemaObjCXX / instantiate-expr.mm
blob08be5f7b91102a58426ca3ba0aa020c6ac7c87f9
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 @interface A {
4 @public
5   int ivar;
7 @property int prop;
8 @end
10 typedef struct objc_object {
11     Class isa;
12 } *id;
14 // Test instantiation of value-dependent ObjCIvarRefExpr,
15 // ObjCIsaRefExpr, and ObjCPropertyRefExpr nodes.
16 A *get_an_A(unsigned);
17 id get_an_id(unsigned);
19 template<unsigned N, typename T, typename U, typename V>
20 void f(U value, V value2) {
21   get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
22   get_an_A(N).prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}}
23   T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}}
26 template void f<6, Class>(int, int);
27 template void f<7, Class>(int*, int); // expected-note{{in instantiation of}}
28 template void f<8, Class>(int, double*); // expected-note{{in instantiation of}}
29 template void f<9, int>(int, int); // expected-note{{in instantiation of}}
31 // Test instantiation of unresolved member reference expressions to an
32 // ivar reference.
33 template<typename T, typename U, typename V>
34 void f2(T ptr, U value, V value2) {
35   ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
36   ptr.prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}}
39 template void f2(A*, int, int);
40 template void f2(A*, int*, int); // expected-note{{instantiation of}}
41 template void f2(A*, int, double*); // expected-note{{instantiation of}}
43 // Test instantiation of unresolved member referfence expressions to
44 // an isa.
45 template<typename T, typename U>
46 void f3(U ptr) {
47   T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}}
50 template void f3<Class>(id);
51 template void f3<int>(id); // expected-note{{instantiation of}}
53 // Implicit setter/getter
54 @interface B
55 - (int)foo;
56 - (void)setFoo:(int)value;
57 @end
59 template<typename T>
60 void f4(B *b, T value) {
61   b.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
64 template void f4(B*, int);
65 template void f4(B*, int*); // expected-note{{in instantiation of function template specialization 'f4<int *>' requested here}}
67 template<typename T, typename U>
68 void f5(T ptr, U value) {
69   ptr.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
72 template void f5(B*, int);
73 template void f5(B*, int*); // expected-note{{in instantiation of function template specialization 'f5<B *, int *>' requested here}}