| 1 |
// { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* i?86-*-freebsd* i?86-*-darwin* } } |
| 2 |
// { dg-require-effective-target ilp32 } |
| 3 |
// { dg-options "-malign-double" } |
| 4 |
// Origin: Alex Samuel <[email protected]> |
| 5 |
|
| 6 |
/* Test the size and alignment of fundamental C types for compliance |
| 7 |
with the IA-64 ABI. */ |
| 8 |
|
| 9 |
template<typename T> |
| 10 |
inline unsigned |
| 11 |
alignmentof () |
| 12 |
{ |
| 13 |
struct S |
| 14 |
{ |
| 15 |
char start_; |
| 16 |
T object_; |
| 17 |
}; |
| 18 |
|
| 19 |
return (unsigned) & ((S *) 0)->object_; |
| 20 |
} |
| 21 |
|
| 22 |
/* Computes the alignment, in bytes, of TYPE. */ |
| 23 |
|
| 24 |
#define alignof(type) (alignmentof<type> ()) |
| 25 |
|
| 26 |
enum A { a }; |
| 27 |
|
| 28 |
int |
| 29 |
main () |
| 30 |
{ |
| 31 |
if (sizeof (char) != 1) |
| 32 |
return 1; |
| 33 |
if (alignof (char) != 1) |
| 34 |
return 2; |
| 35 |
if (sizeof (signed char) != 1) |
| 36 |
return 3; |
| 37 |
if (alignof (signed char) != 1) |
| 38 |
return 4; |
| 39 |
if (sizeof (unsigned char) != 1) |
| 40 |
return 5; |
| 41 |
if (alignof (unsigned char) != 1) |
| 42 |
return 6; |
| 43 |
if (sizeof (short) != 2) |
| 44 |
return 7; |
| 45 |
if (alignof (short) != 2) |
| 46 |
return 8; |
| 47 |
if (sizeof (signed short) != 2) |
| 48 |
return 9; |
| 49 |
if (alignof (signed short) != 2) |
| 50 |
return 10; |
| 51 |
if (sizeof (unsigned short) != 2) |
| 52 |
return 11; |
| 53 |
if (alignof (unsigned short) != 2) |
| 54 |
return 12; |
| 55 |
if (sizeof (int) != 4) |
| 56 |
return 13; |
| 57 |
if (alignof (int) != 4) |
| 58 |
return 14; |
| 59 |
if (sizeof (signed int) != 4) |
| 60 |
return 15; |
| 61 |
if (alignof (signed int) != 4) |
| 62 |
return 16; |
| 63 |
if (sizeof (unsigned int) != 4) |
| 64 |
return 17; |
| 65 |
if (alignof (unsigned int) != 4) |
| 66 |
return 18; |
| 67 |
if (sizeof (enum A) != 4) |
| 68 |
return 19; |
| 69 |
if (alignof (enum A) != 4) |
| 70 |
return 20; |
| 71 |
#ifdef HAVE_IA64_TYPES |
| 72 |
if (sizeof (__int64) != 8) |
| 73 |
return 21; |
| 74 |
if (alignof (__int64) != 8) |
| 75 |
return 22; |
| 76 |
if (sizeof (signed __int64) != 8) |
| 77 |
return 23; |
| 78 |
if (alignof (signed ___int64) != 8) |
| 79 |
return 24; |
| 80 |
if (sizeof (unsigned __int64) != 8) |
| 81 |
return 25; |
| 82 |
if (alignof (unsigned __int64) != 8) |
| 83 |
return 26; |
| 84 |
if (sizeof (__int128) != 16) |
| 85 |
return 27; |
| 86 |
if (alignof (__int128) != 16) |
| 87 |
return 28; |
| 88 |
if (sizeof (signed __int128) != 16) |
| 89 |
return 29; |
| 90 |
if (alignof (signed ___int128) != 16) |
| 91 |
return 30; |
| 92 |
if (sizeof (unsigned __int128) != 16) |
| 93 |
return 31; |
| 94 |
if (alignof (unsigned ___int128) != 16) |
| 95 |
return 32; |
| 96 |
#endif /* HAVE_IA64_TYPES */ |
| 97 |
if (sizeof (void *) != 4) |
| 98 |
return 33; |
| 99 |
if (alignof (void *) != 4) |
| 100 |
return 34; |
| 101 |
if (sizeof (void (*) ()) != 4) |
| 102 |
return 35; |
| 103 |
if (alignof (void (*) ()) != 4) |
| 104 |
return 36; |
| 105 |
if (sizeof (float) != 4) |
| 106 |
return 37; |
| 107 |
if (alignof (float) != 4) |
| 108 |
return 38; |
| 109 |
if (sizeof (double) != 8) |
| 110 |
return 39; |
| 111 |
if (alignof (double) != 8) |
| 112 |
return 40; |
| 113 |
#ifdef HAVE_IA64_TYPES |
| 114 |
if (sizeof (__float80) != 16) |
| 115 |
return 41; |
| 116 |
if (alignof (__float80) != 16) |
| 117 |
return 42; |
| 118 |
if (sizeof (__float128) != 16) |
| 119 |
return 43; |
| 120 |
if (alignof (__float128) != 16) |
| 121 |
return 44; |
| 122 |
#endif /* HAVE_IA64_TYPES */ |
| 123 |
|
| 124 |
return 0; |
| 125 |
} |