1// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3// rdar://11203853
4
5typedef unsigned long size_t;
6
7void *sel_registerName(const char *);
8
9@protocol P @end
10
11@interface NSMutableArray
12#if __has_feature(objc_subscripting)
13- (id)objectAtIndexedSubscript:(size_t)index;
14- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
15#endif
16@end
17
18#if __has_feature(objc_subscripting)
19@interface XNSMutableArray
20- (id)objectAtIndexedSubscript:(size_t)index;
21- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
22#endif
23@end
24
25@interface NSMutableDictionary
26- (id)objectForKeyedSubscript:(id)key;
27- (void)setObject:(id)object forKeyedSubscript:(id)key;
28@end
29
30@class NSString;
31
32int main() {
33  NSMutableArray<P> * array;
34  id oldObject = array[10];
35
36  array[10] = oldObject;
37
38  id unknown_array;
39  oldObject = unknown_array[1];
40
41  unknown_array[1] = oldObject;
42
43  NSMutableDictionary *dictionary;
44  NSString *key;
45  id newObject;
46  oldObject = dictionary[key];
47  dictionary[key] = newObject;  // replace oldObject with newObject
48}
49
50