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