Jim Grosbach | f794705 | 2012-07-09 18:34:21 +0000 | [diff] [blame] | 1 | // REQUIRES: arm-registered-target |
James Molloy | e45b9b7 | 2012-03-12 09:14:10 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 3 | // expected-no-diagnostics |
James Molloy | e45b9b7 | 2012-03-12 09:14:10 +0000 | [diff] [blame] | 4 | |
| 5 | #include <stddef.h> |
| 6 | |
| 7 | struct t1 |
| 8 | { |
| 9 | int foo : 1; |
| 10 | char : 0; |
| 11 | char bar; |
| 12 | }; |
| 13 | static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1]; |
| 14 | static int arr1_sizeof[(sizeof(struct t1) == 4) ? 0 : -1]; |
| 15 | |
| 16 | struct t2 |
| 17 | { |
| 18 | int foo : 1; |
| 19 | short : 0; |
| 20 | char bar; |
| 21 | }; |
| 22 | static int arr2_offset[(offsetof(struct t2, bar) == 2) ? 0 : -1]; |
| 23 | static int arr2_sizeof[(sizeof(struct t2) == 4) ? 0 : -1]; |
| 24 | |
| 25 | struct t3 |
| 26 | { |
| 27 | int foo : 1; |
| 28 | int : 0; |
| 29 | char bar; |
| 30 | }; |
| 31 | static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1]; |
| 32 | static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1]; |
| 33 | |
| 34 | struct t4 |
| 35 | { |
| 36 | int foo : 1; |
| 37 | long : 0; |
| 38 | char bar; |
| 39 | }; |
| 40 | static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1]; |
| 41 | static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1]; |
| 42 | |
| 43 | struct t5 |
| 44 | { |
| 45 | int foo : 1; |
| 46 | long long : 0; |
| 47 | char bar; |
| 48 | }; |
| 49 | static int arr5_offset[(offsetof(struct t5, bar) == 8) ? 0 : -1]; |
| 50 | static int arr5_sizeof[(sizeof(struct t5) == 16) ? 0 : -1]; |
| 51 | |
| 52 | struct t6 |
| 53 | { |
| 54 | int foo : 1; |
| 55 | char : 0; |
| 56 | char bar : 1; |
| 57 | char bar2; |
| 58 | }; |
| 59 | static int arr6_offset[(offsetof(struct t6, bar2) == 2) ? 0 : -1]; |
| 60 | static int arr6_sizeof[(sizeof(struct t6) == 4) ? 0 : -1]; |
| 61 | |
| 62 | struct t7 |
| 63 | { |
| 64 | int foo : 1; |
| 65 | short : 0; |
| 66 | char bar1 : 1; |
| 67 | char bar2; |
| 68 | }; |
| 69 | static int arr7_offset[(offsetof(struct t7, bar2) == 3) ? 0 : -1]; |
| 70 | static int arr7_sizeof[(sizeof(struct t7) == 4) ? 0 : -1]; |
| 71 | |
| 72 | struct t8 |
| 73 | { |
| 74 | int foo : 1; |
| 75 | int : 0; |
| 76 | char bar1 : 1; |
| 77 | char bar2; |
| 78 | }; |
| 79 | static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1]; |
| 80 | static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1]; |
| 81 | |
| 82 | struct t9 |
| 83 | { |
| 84 | int foo : 1; |
| 85 | long : 0; |
| 86 | char bar1 : 1; |
| 87 | char bar2; |
| 88 | }; |
| 89 | static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1]; |
| 90 | static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1]; |
| 91 | |
| 92 | struct t10 |
| 93 | { |
| 94 | int foo : 1; |
| 95 | long long : 0; |
| 96 | char bar1 : 1; |
| 97 | char bar2; |
| 98 | }; |
| 99 | static int arr10_offset[(offsetof(struct t10, bar2) == 9) ? 0 : -1]; |
| 100 | static int arr10_sizeof[(sizeof(struct t10) == 16) ? 0 : -1]; |
| 101 | |
| 102 | struct t11 |
| 103 | { |
| 104 | int foo : 1; |
| 105 | long long : 0; |
| 106 | char : 0; |
| 107 | char bar1 : 1; |
| 108 | char bar2; |
| 109 | }; |
| 110 | static int arr11_offset[(offsetof(struct t11, bar2) == 9) ? 0 : -1]; |
| 111 | static int arr11_sizeof[(sizeof(struct t11) == 16) ? 0 : -1]; |
| 112 | |
| 113 | struct t12 |
| 114 | { |
| 115 | int foo : 1; |
| 116 | char : 0; |
| 117 | long long : 0; |
| 118 | char : 0; |
| 119 | char bar; |
| 120 | }; |
| 121 | static int arr12_offset[(offsetof(struct t12, bar) == 8) ? 0 : -1]; |
| 122 | static int arr12_sizeof[(sizeof(struct t12) == 16) ? 0 : -1]; |
| 123 | |
| 124 | struct t13 |
| 125 | { |
| 126 | char foo; |
| 127 | long : 0; |
| 128 | char bar; |
| 129 | }; |
| 130 | static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1]; |
| 131 | static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1]; |
| 132 | |
| 133 | struct t14 |
| 134 | { |
| 135 | char foo1; |
| 136 | int : 0; |
| 137 | char foo2 : 1; |
| 138 | short foo3 : 16; |
| 139 | char : 0; |
| 140 | short foo4 : 16; |
| 141 | char bar1; |
| 142 | int : 0; |
| 143 | char bar2; |
| 144 | }; |
| 145 | static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1]; |
| 146 | static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1]; |
| 147 | static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1]; |
| 148 | |
| 149 | struct t15 |
| 150 | { |
| 151 | char foo; |
| 152 | char : 0; |
| 153 | int : 0; |
| 154 | char bar; |
| 155 | long : 0; |
| 156 | char : 0; |
| 157 | }; |
| 158 | static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1]; |
| 159 | static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1]; |
| 160 | |
| 161 | struct t16 |
| 162 | { |
| 163 | long : 0; |
| 164 | char bar; |
| 165 | }; |
| 166 | static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1]; |
| 167 | static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1]; |
| 168 | |
| 169 | struct t17 |
| 170 | { |
| 171 | char foo; |
| 172 | long : 0; |
| 173 | long : 0; |
| 174 | char : 0; |
| 175 | char bar; |
| 176 | }; |
| 177 | static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1]; |
| 178 | static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1]; |
| 179 | |
| 180 | struct t18 |
| 181 | { |
| 182 | long : 0; |
| 183 | long : 0; |
| 184 | char : 0; |
| 185 | }; |
| 186 | static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1]; |
| 187 | |
| 188 | struct t19 |
| 189 | { |
| 190 | char foo1; |
| 191 | long foo2 : 1; |
| 192 | char : 0; |
| 193 | long foo3 : 32; |
| 194 | char bar; |
| 195 | }; |
| 196 | static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1]; |
| 197 | static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1]; |
| 198 | |
| 199 | struct t20 |
| 200 | { |
| 201 | short : 0; |
| 202 | int foo : 1; |
| 203 | long : 0; |
| 204 | char bar; |
| 205 | }; |
| 206 | static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1]; |
| 207 | static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1]; |
| 208 | |
| 209 | struct t21 |
| 210 | { |
| 211 | short : 0; |
| 212 | int foo1 : 1; |
| 213 | char : 0; |
| 214 | int foo2 : 16; |
| 215 | long : 0; |
| 216 | char bar1; |
| 217 | int bar2; |
| 218 | long bar3; |
| 219 | char foo3 : 8; |
| 220 | char : 0; |
| 221 | long : 0; |
| 222 | int foo4 : 32; |
| 223 | short foo5: 1; |
| 224 | long bar4; |
| 225 | short foo6: 16; |
| 226 | short foo7: 16; |
| 227 | short foo8: 16; |
| 228 | }; |
| 229 | static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 4) ? 0 : -1]; |
| 230 | static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 8) ? 0 : -1]; |
| 231 | static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 12) ? 0 : -1]; |
| 232 | static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 28) ? 0 : -1]; |
| 233 | static int arr21_sizeof[(sizeof(struct t21) == 40) ? 0 : -1]; |
| 234 | |
| 235 | int main() { |
| 236 | return 0; |
| 237 | } |
| 238 | |