1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi apcs-gnu %s -verify 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi aapcs %s -verify 3*f4a2713aSLionel Sambuc // expected-no-diagnostics 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc #define check(name, cond) int _##name##_check[(cond) ? 1 : -1] 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc struct s0 { char field0; double field1; }; 8*f4a2713aSLionel Sambuc #ifdef __ARM_EABI__ 9*f4a2713aSLionel Sambuc check(s0_size, sizeof(struct s0) == 16); 10*f4a2713aSLionel Sambuc #else 11*f4a2713aSLionel Sambuc check(s0_size, sizeof(struct s0) == 12); 12*f4a2713aSLionel Sambuc #endif 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc struct s1 { char field0; long double field1; }; 15*f4a2713aSLionel Sambuc #ifdef __ARM_EABI__ 16*f4a2713aSLionel Sambuc check(s1_size, sizeof(struct s1) == 16); 17*f4a2713aSLionel Sambuc #else 18*f4a2713aSLionel Sambuc check(s1_size, sizeof(struct s1) == 12); 19*f4a2713aSLionel Sambuc #endif 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc struct s2 { 22*f4a2713aSLionel Sambuc short field0; 23*f4a2713aSLionel Sambuc int field1 : 24; 24*f4a2713aSLionel Sambuc char field2; 25*f4a2713aSLionel Sambuc }; 26*f4a2713aSLionel Sambuc #ifdef __ARM_EABI__ 27*f4a2713aSLionel Sambuc check(s2_size, sizeof(struct s2) == 8); 28*f4a2713aSLionel Sambuc check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0); 29*f4a2713aSLionel Sambuc check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 7); 30*f4a2713aSLionel Sambuc #else 31*f4a2713aSLionel Sambuc check(s2_size, sizeof(struct s2) == 6); 32*f4a2713aSLionel Sambuc check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0); 33*f4a2713aSLionel Sambuc check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 5); 34*f4a2713aSLionel Sambuc #endif 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc struct s3 { 37*f4a2713aSLionel Sambuc short field0; 38*f4a2713aSLionel Sambuc int field1 : 24 __attribute__((aligned(4))); 39*f4a2713aSLionel Sambuc char field2; 40*f4a2713aSLionel Sambuc }; 41*f4a2713aSLionel Sambuc check(s3_size, sizeof(struct s3) == 8); 42*f4a2713aSLionel Sambuc check(s3_offset_0, __builtin_offsetof(struct s3, field0) == 0); 43*f4a2713aSLionel Sambuc check(s3_offset_1, __builtin_offsetof(struct s3, field2) == 7); 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc struct s4 { 46*f4a2713aSLionel Sambuc int field0 : 4; 47*f4a2713aSLionel Sambuc }; 48*f4a2713aSLionel Sambuc #ifdef __ARM_EABI__ 49*f4a2713aSLionel Sambuc check(s4_size, sizeof(struct s4) == 4); 50*f4a2713aSLionel Sambuc check(s4_align, __alignof(struct s4) == 4); 51*f4a2713aSLionel Sambuc #else 52*f4a2713aSLionel Sambuc check(s4_size, sizeof(struct s4) == 1); 53*f4a2713aSLionel Sambuc check(s4_align, __alignof(struct s4) == 1); 54*f4a2713aSLionel Sambuc #endif 55