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