Douglas Gregor | f9b9eab | 2010-04-26 20:11:03 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | @interface A { |
| 4 | @public |
| 5 | int ivar; |
| 6 | } |
| 7 | @end |
| 8 | |
| 9 | typedef struct objc_object { |
| 10 | Class isa; |
| 11 | } *id; |
| 12 | |
| 13 | // Test instantiation of value-dependent ObjCIvarRefExpr and |
| 14 | // ObjCIsaRefExpr nodes. |
| 15 | A *get_an_A(unsigned); |
| 16 | id get_an_id(unsigned); |
| 17 | |
| 18 | template<unsigned N, typename T, typename U> |
| 19 | void f(U value) { |
| 20 | get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} |
| 21 | T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} |
| 22 | } |
| 23 | |
| 24 | template void f<6, Class>(int); |
| 25 | template void f<7, Class>(int*); // expected-note{{in instantiation of}} |
| 26 | template void f<8, int>(int); // expected-note{{in instantiation of}} |
| 27 | |
| 28 | // Test instantiation of unresolved member reference expressions to an |
| 29 | // ivar reference. |
| 30 | template<typename T, typename U> |
| 31 | void f2(T ptr, U value) { |
| 32 | ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} |
| 33 | } |
| 34 | |
| 35 | template void f2(A*, int); |
| 36 | template void f2(A*, int*); // expected-note{{instantiation of}} |
| 37 | |
| 38 | // Test instantiation of unresolved member referfence expressions to |
| 39 | // an isa. |
| 40 | template<typename T, typename U> |
| 41 | void f3(U ptr) { |
| 42 | T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} |
| 43 | } |
| 44 | |
| 45 | template void f3<Class>(id); |
| 46 | template void f3<int>(id); // expected-note{{instantiation of}} |