[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Rewriter / objc-modern-container-subscript.mm
blobcdcff03b770b967bab701b017550e910c2a46de7
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
5 typedef unsigned long size_t;
7 void *sel_registerName(const char *);
9 @protocol P @end
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
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
25 @interface NSMutableDictionary
26 - (id)objectForKeyedSubscript:(id)key;
27 - (void)setObject:(id)object forKeyedSubscript:(id)key;
28 @end
30 @class NSString;
32 int main() {
33   NSMutableArray<P> * array;
34   id oldObject = array[10];
36   array[10] = oldObject;
38   id unknown_array;
39   oldObject = unknown_array[1];
41   unknown_array[1] = oldObject;
43   NSMutableDictionary *dictionary;
44   NSString *key;
45   id newObject;
46   oldObject = dictionary[key];
47   dictionary[key] = newObject;  // replace oldObject with newObject