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