diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
| commit | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (patch) | |
| tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /test/CodeGenObjCXX/objc-container-subscripting.mm | |
| parent | 9da628931ebf2609493570f87824ca22402cc65f (diff) | |
Notes
Diffstat (limited to 'test/CodeGenObjCXX/objc-container-subscripting.mm')
| -rw-r--r-- | test/CodeGenObjCXX/objc-container-subscripting.mm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/CodeGenObjCXX/objc-container-subscripting.mm b/test/CodeGenObjCXX/objc-container-subscripting.mm new file mode 100644 index 000000000000..dfe48e9d6dc8 --- /dev/null +++ b/test/CodeGenObjCXX/objc-container-subscripting.mm @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s + +typedef unsigned int size_t; +@protocol P @end + +@interface NSMutableArray +- (id)objectAtIndexedSubscript:(size_t)index; +- (void)setObject:(id)object atIndexedSubscript:(size_t)index; +@end + +struct S { + operator unsigned int (); + operator id (); +}; + +@interface NSMutableDictionary +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +int main() { + NSMutableArray<P> * array; + S s; + id oldObject = array[(int)s]; + + NSMutableDictionary<P> *dict; + dict[(id)s] = oldObject; + oldObject = dict[(id)s]; + +} + +template <class T> void test2(NSMutableArray *a) { + a[10] = 0; +} +template void test2<int>(NSMutableArray*); +// CHECK: define weak_odr void @_Z5test2IiEvP14NSMutableArray +// CHECK: @objc_msgSend +// CHECK: ret void + + +template <class T> void test3(NSMutableArray *a) { + a[sizeof(T)] = 0; +} + +template void test3<int>(NSMutableArray*); +// CHECK: define weak_odr void @_Z5test3IiEvP14NSMutableArray +// CHECK: @objc_msgSend +// CHECK: ret void + +// CHECK: define void @_Z11static_dataP14NSMutableArray +void static_data(NSMutableArray *array) { + // CHECK: call i32 @__cxa_guard_acquire + // CHECK: {{call i8*.*@objc_msgSend }} + // CHECK: call void @__cxa_guard_release + static id x = array[4]; + // CHECK: ret void +} |
