1 // RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s 2 // RUN: FileCheck < %t %s 3 // 4 // CHECK: @OBJC_METH_VAR_TYPE_.34 = private global [16 x i8] c"v12@0:4[3[4@]]8\00" 5 6 @class Int1; 7 8 struct Innermost { 9 unsigned char a, b; 10 }; 11 12 @interface Int1 { 13 signed char a, b; 14 struct Innermost *innermost; 15 } 16 @end 17 18 @implementation Int1 19 @end 20 21 @interface Base 22 { 23 struct objc_class *isa; 24 int full; 25 int full2: 32; 26 int _refs: 8; 27 int field2: 3; 28 unsigned f3: 8; 29 short cc; 30 unsigned g: 16; 31 int r2: 8; 32 int r3: 8; 33 int r4: 2; 34 int r5: 8; 35 char c; 36 } 37 @end 38 39 @interface Derived: Base 40 { 41 char d; 42 int _field3: 6; 43 } 44 @end 45 46 @implementation Base 47 @end 48 49 @implementation Derived 50 @end 51 52 @interface B1 53 { 54 struct objc_class *isa; 55 Int1 *sBase; 56 char c; 57 } 58 @end 59 60 @implementation B1 61 @end 62 63 @interface Test 64 { 65 int ivar; 66 __attribute__((objc_gc(weak))) SEL selector; 67 } 68 -(void) test3: (Test* [3] [4])b ; 69 - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3; 70 @end 71 72 @implementation Test 73 -(void) test3: (Test* [3] [4])b {} 74 - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3 {} 75 @end 76 77 struct S { int iS; }; 78 79 @interface Object 80 { 81 Class isa; 82 } 83 @end 84 typedef Object MyObj; 85 86 int main() 87 { 88 const char *en = @encode(Derived); 89 const char *eb = @encode(B1); 90 const char *es = @encode(const struct S *); 91 const char *ec = @encode(const struct S); 92 const char *ee = @encode(MyObj *const); 93 } 94 95 // CHECK: @g0 = constant [15 x i8] c"{Innermost=CC}\00" 96 const char g0[] = @encode(struct Innermost); 97 98 // CHECK: @g1 = constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00" 99 const char g1[] = @encode(Derived); 100 101 // CHECK: @g2 = constant [9 x i8] c"{B1=#@c}\00" 102 const char g2[] = @encode(B1); 103 104 // CHECK: @g3 = constant [8 x i8] c"r^{S=i}\00" 105 const char g3[] = @encode(const struct S *); 106 107 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00" 108 const char g4[] = @encode(const struct S); 109 110 // CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00" 111 const char g5[] = @encode(MyObj * const); 112 113 //// 114 115 enum Enum1X { one, two, three, four }; 116 117 @interface Base1X { 118 unsigned a: 2; 119 int b: 3; 120 enum Enum1X c: 4; 121 unsigned d: 5; 122 } 123 @end 124 125 @interface Derived1X: Base1X { 126 signed e: 5; 127 int f: 4; 128 enum Enum1X g: 3; 129 } 130 @end 131 132 @implementation Base1X @end 133 134 @implementation Derived1X @end 135 136 // CHECK: @g6 = constant [18 x i8] c"{Base1X=b2b3b4b5}\00" 137 const char g6[] = @encode(Base1X); 138 139 // CHECK: @g7 = constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00" 140 const char g7[] = @encode(Derived1X); 141 142 // CHECK: @g8 = constant [7 x i8] c"{s8=D}\00" 143 struct s8 { 144 long double x; 145 }; 146 const char g8[] = @encode(struct s8); 147 148 // CHECK: @g9 = constant [11 x i8] c"{S9=i[0i]}\00" 149 struct S9 { 150 int x; 151 int flex[]; 152 }; 153 const char g9[] = @encode(struct S9); 154 155 struct f 156 { 157 int i; 158 struct{} g[4]; 159 int tt; 160 }; 161 162 // CHECK: @g10 = constant [14 x i8] c"{f=i[4{?=}]i}\00" 163 const char g10[] = @encode(struct f); 164 165 // rdar://9622422 166 // CHECK: @g11 = constant [2 x i8] c"v\00" 167 const char g11[] = @encode(void); 168 169 // PR14628 170 // CHECK: @g12 = constant [3 x i8] c"Ai\00" 171 const char g12[] = @encode(_Atomic(int)); 172 173 // rdar://15824769 174 id test_id = 0; 175 Class test_class = 0; 176 const char g13[] = @encode(__typeof__(*test_class)); 177 const char g14[] = @encode(__typeof__(*test_id)); 178 // CHECK: constant [14 x i8] c"{objc_class=}\00" 179 // CHECK: constant [15 x i8] c"{objc_object=}\00" 180 181 // CHECK: @g15 = constant [2 x i8] c":\00" 182 const char g15[] = @encode(SEL); 183