xref: /aosp_15_r20/external/clang/test/PCH/subscripting-literals.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.nopch.ll %s
2*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-pch -o %t.pch %s
3*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.pch.ll %s -include-pch %t.pch
4*67e74705SXin Li// REQUIRES: x86-registered-target
5*67e74705SXin Li// RUN: diff %t.nopch.ll %t.pch.ll
6*67e74705SXin Li
7*67e74705SXin Li#ifndef HEADER
8*67e74705SXin Li#define HEADER
9*67e74705SXin Li
10*67e74705SXin Li@interface NSArray
11*67e74705SXin Li- (id)objectAtIndexedSubscript:(int)index;
12*67e74705SXin Li+ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
13*67e74705SXin Li@end
14*67e74705SXin Li
15*67e74705SXin Li@interface NSMutableArray : NSArray
16*67e74705SXin Li- (void)setObject:(id)object atIndexedSubscript:(int)index;
17*67e74705SXin Li@end
18*67e74705SXin Li
19*67e74705SXin Li@interface NSDictionary
20*67e74705SXin Li- (id)objectForKeyedSubscript:(id)key;
21*67e74705SXin Li+ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
22*67e74705SXin Li@end
23*67e74705SXin Li
24*67e74705SXin Li@interface NSMutableDictionary : NSDictionary
25*67e74705SXin Li- (void)setObject:(id)object forKeyedSubscript:(id)key;
26*67e74705SXin Li@end
27*67e74705SXin Li
28*67e74705SXin Li@interface NSNumber
29*67e74705SXin Li+ (NSNumber *)numberWithInt:(int)value;
30*67e74705SXin Li@end
31*67e74705SXin Li
32*67e74705SXin Li@class NSString;
33*67e74705SXin Li
34*67e74705SXin Li@interface NSValue
35*67e74705SXin Li+ (NSValue *)valueWithBytes:(const void *)bytes objCType:(const char *)type;
36*67e74705SXin Li@end
37*67e74705SXin Li
38*67e74705SXin Litypedef struct __attribute__((objc_boxable)) _some_struct {
39*67e74705SXin Li  int dummy;
40*67e74705SXin Li} some_struct;
41*67e74705SXin Li
42*67e74705SXin Liid testArray(int idx, id p) {
43*67e74705SXin Li  NSMutableArray *array;
44*67e74705SXin Li  array[idx] = p;
45*67e74705SXin Li  NSArray *arr = @[ p, @7 ];
46*67e74705SXin Li  return array[idx];
47*67e74705SXin Li}
48*67e74705SXin Li
49*67e74705SXin Livoid testDict(NSString *key, id newObject, id oldObject) {
50*67e74705SXin Li  NSMutableDictionary *dictionary;
51*67e74705SXin Li  oldObject = dictionary[key];
52*67e74705SXin Li  dictionary[key] = newObject;
53*67e74705SXin Li  NSDictionary *dict = @{ key: newObject, key: oldObject };
54*67e74705SXin Li}
55*67e74705SXin Li
56*67e74705SXin Livoid testBoxableValue() {
57*67e74705SXin Li  some_struct ss;
58*67e74705SXin Li  id value = @(ss);
59*67e74705SXin Li}
60*67e74705SXin Li
61*67e74705SXin Li#endif
62