blob: 264ea634e87dda09bb0fc10474564250b95348c9 [file] [log] [blame]
Douglas Gregorf9b9eab2010-04-26 20:11:03 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3@interface A {
4@public
5 int ivar;
6}
7@end
8
9typedef struct objc_object {
10 Class isa;
11} *id;
12
13// Test instantiation of value-dependent ObjCIvarRefExpr and
14// ObjCIsaRefExpr nodes.
15A *get_an_A(unsigned);
16id get_an_id(unsigned);
17
18template<unsigned N, typename T, typename U>
19void 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
24template void f<6, Class>(int);
25template void f<7, Class>(int*); // expected-note{{in instantiation of}}
26template void f<8, int>(int); // expected-note{{in instantiation of}}
27
28// Test instantiation of unresolved member reference expressions to an
29// ivar reference.
30template<typename T, typename U>
31void f2(T ptr, U value) {
32 ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
33}
34
35template void f2(A*, int);
36template void f2(A*, int*); // expected-note{{instantiation of}}
37
38// Test instantiation of unresolved member referfence expressions to
39// an isa.
40template<typename T, typename U>
41void 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
45template void f3<Class>(id);
46template void f3<int>(id); // expected-note{{instantiation of}}