1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s |
2 | // RUN: grep -F '@objc_assign_global' %t | count 26 |
3 | |
4 | @class NSObject; |
5 | typedef const struct __CFDictionary * CFDictionaryRef; |
6 | typedef struct { |
7 | id element; |
8 | id elementArray[10]; |
9 | __strong CFDictionaryRef cfElement; |
10 | __strong CFDictionaryRef cfElementArray[10]; |
11 | } struct_with_ids_t; |
12 | |
13 | |
14 | // assignments to these should generate objc_assign_global |
15 | @interface A |
16 | @end |
17 | |
18 | typedef struct s0 { |
19 | A *a[4]; |
20 | } T; |
21 | |
22 | T g0; |
23 | |
24 | extern id FileExternID; |
25 | static id FileStaticID; |
26 | id GlobalId; |
27 | id GlobalArray[20]; |
28 | NSObject *GlobalObject; |
29 | NSObject *GlobalObjectArray[20]; |
30 | __strong CFDictionaryRef Gdict; |
31 | __strong CFDictionaryRef Gdictarray[10]; |
32 | struct_with_ids_t GlobalStruct; |
33 | struct_with_ids_t GlobalStructArray[10]; |
34 | |
35 | #define ASSIGNTEST(expr, global) expr = rhs |
36 | void *rhs = 0; |
37 | |
38 | int main() { |
39 | static id staticGlobalId; |
40 | static id staticGlobalArray[20]; |
41 | static NSObject *staticGlobalObject; |
42 | static NSObject *staticGlobalObjectArray[20]; |
43 | static __strong CFDictionaryRef staticGdict; |
44 | static __strong CFDictionaryRef staticGdictarray[10]; |
45 | static struct_with_ids_t staticGlobalStruct; |
46 | static struct_with_ids_t staticGlobalStructArray[10]; |
47 | extern id ExID; |
48 | id localID; |
49 | |
50 | ASSIGNTEST(GlobalId, GlobalAssigns); // objc_assign_global |
51 | ASSIGNTEST(GlobalArray[0], GlobalAssigns); // objc_assign_global |
52 | ASSIGNTEST(GlobalObject, GlobalAssigns); // objc_assign_global |
53 | ASSIGNTEST(GlobalObjectArray[0], GlobalAssigns); // objc_assign_global |
54 | ASSIGNTEST(Gdict, GlobalAssigns); // objc_assign_global |
55 | ASSIGNTEST(Gdictarray[1], GlobalAssigns); // objc_assign_global |
56 | |
57 | ASSIGNTEST(GlobalStruct.element, GlobalAssigns); // objc_assign_global |
58 | ASSIGNTEST(GlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global |
59 | ASSIGNTEST(GlobalStruct.cfElement, GlobalAssigns); // objc_assign_global |
60 | ASSIGNTEST(GlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global |
61 | |
62 | ASSIGNTEST(staticGlobalId, GlobalAssigns); // objc_assign_global |
63 | ASSIGNTEST(staticGlobalArray[0], GlobalAssigns); // objc_assign_global |
64 | ASSIGNTEST(staticGlobalObject, GlobalAssigns); // objc_assign_global |
65 | ASSIGNTEST(staticGlobalObjectArray[0], GlobalAssigns); // objc_assign_global |
66 | ASSIGNTEST(staticGdict, GlobalAssigns); // objc_assign_global |
67 | ASSIGNTEST(staticGdictarray[1], GlobalAssigns); // objc_assign_global |
68 | |
69 | ASSIGNTEST(staticGlobalStruct.element, GlobalAssigns); // objc_assign_global |
70 | ASSIGNTEST(staticGlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global |
71 | ASSIGNTEST(staticGlobalStruct.cfElement, GlobalAssigns); // objc_assign_global |
72 | ASSIGNTEST(staticGlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global |
73 | |
74 | ExID = 0; |
75 | localID = 0; |
76 | FileStaticID = 0; |
77 | FileExternID=0; |
78 | g0.a[0] = 0; |
79 | ((T*) &g0)->a[0] = 0; |
80 | } |
81 | |