diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-04-26 20:11:03 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-04-26 20:11:03 +0000 |
| commit | d51d90dd04372abfe1e86307d2c05fb9916ddca9 (patch) | |
| tree | 0dd5fe4643540e47840e86da19cecca6b8515291 /clang/test | |
| parent | 91358585d741ac32f8685c08ca698f049de632ff (diff) | |
| download | bcm5719-llvm-d51d90dd04372abfe1e86307d2c05fb9916ddca9.tar.gz bcm5719-llvm-d51d90dd04372abfe1e86307d2c05fb9916ddca9.zip | |
Implement template instantiation for value-dependent Objective-C ivar
references and isa expressions. Also, test template instantiation of
unresolved member references to Objective-C ivar references and isa
expressions.
llvm-svn: 102374
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaObjCXX/instantiate-expr.mm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/SemaObjCXX/instantiate-expr.mm b/clang/test/SemaObjCXX/instantiate-expr.mm new file mode 100644 index 00000000000..264ea634e87 --- /dev/null +++ b/clang/test/SemaObjCXX/instantiate-expr.mm @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface A { +@public + int ivar; +} +@end + +typedef struct objc_object { + Class isa; +} *id; + +// Test instantiation of value-dependent ObjCIvarRefExpr and +// ObjCIsaRefExpr nodes. +A *get_an_A(unsigned); +id get_an_id(unsigned); + +template<unsigned N, typename T, typename U> +void f(U value) { + get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} + T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} +} + +template void f<6, Class>(int); +template void f<7, Class>(int*); // expected-note{{in instantiation of}} +template void f<8, int>(int); // expected-note{{in instantiation of}} + +// Test instantiation of unresolved member reference expressions to an +// ivar reference. +template<typename T, typename U> +void f2(T ptr, U value) { + ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}} +} + +template void f2(A*, int); +template void f2(A*, int*); // expected-note{{instantiation of}} + +// Test instantiation of unresolved member referfence expressions to +// an isa. +template<typename T, typename U> +void f3(U ptr) { + T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} +} + +template void f3<Class>(id); +template void f3<int>(id); // expected-note{{instantiation of}} |

