aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.abi/align.C
blob: 3f691e2909ed6d477de4c3f4446cbfbd278b83f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } }
// { dg-require-effective-target ilp32 }
// { dg-options "-malign-double" }
// Origin: Alex Samuel <samuel@codesourcery.com>

/* Test the size and alignment of fundamental C types for compliance
   with the IA-64 ABI.  */

template<typename T>
inline unsigned
alignmentof ()
{
  struct S
  {
    char start_;
    T object_;
  };

  return (unsigned) & ((S *) 0)->object_;
}

/* Computes the alignment, in bytes, of TYPE.  */

#define alignof(type) (alignmentof<type> ())

enum A { a };

int
main ()
{
  if (sizeof  (char)                    !=  1)
    return 1;
  if (alignof (char)                    !=  1)
    return 2;
  if (sizeof  (signed char)             !=  1)
    return 3;
  if (alignof (signed char)             !=  1)
    return 4;
  if (sizeof  (unsigned char)           !=  1)
    return 5;  
  if (alignof (unsigned char)           !=  1)
    return 6;
  if (sizeof  (short)                   !=  2)
    return 7;
  if (alignof (short)                   !=  2)
    return 8;
  if (sizeof  (signed short)            !=  2)
    return 9;
  if (alignof (signed short)            !=  2)
    return 10;
  if (sizeof  (unsigned short)          !=  2)
    return 11;
  if (alignof (unsigned short)          !=  2)
    return 12;
  if (sizeof  (int)                     !=  4)
    return 13;
  if (alignof (int)                     !=  4)
    return 14;
  if (sizeof  (signed int)              !=  4)
    return 15;
  if (alignof (signed int)              !=  4)
    return 16;
  if (sizeof  (unsigned int)            !=  4)
    return 17;
  if (alignof (unsigned int)            !=  4)
    return 18;
  if (sizeof  (enum A)                  !=  4)
    return 19;
  if (alignof (enum A)                  !=  4)
    return 20;
#ifdef HAVE_IA64_TYPES
  if (sizeof  (__int64)                 !=  8)
    return 21;
  if (alignof (__int64)                 !=  8)
    return 22;
  if (sizeof  (signed __int64)          !=  8)
    return 23;
  if (alignof (signed ___int64)         !=  8)
    return 24;
  if (sizeof  (unsigned __int64)        !=  8)
    return 25;
  if (alignof (unsigned __int64)        !=  8)
    return 26;
  if (sizeof  (__int128)                != 16)
    return 27;
  if (alignof (__int128)                != 16)
    return 28;
  if (sizeof  (signed __int128)         != 16)
    return 29;
  if (alignof (signed ___int128)        != 16)
    return 30;
  if (sizeof  (unsigned __int128)       != 16)
    return 31;
  if (alignof (unsigned ___int128)      != 16)
    return 32;
#endif  /* HAVE_IA64_TYPES  */
  if (sizeof  (void *)                  !=  4)
    return 33;
  if (alignof (void *)                  !=  4)
    return 34;
  if (sizeof  (void (*) ())             !=  4)
    return 35;
  if (alignof (void (*) ())             !=  4)
    return 36;
  if (sizeof  (float)                   !=  4)
    return 37;
  if (alignof (float)                   !=  4)
    return 38;
  if (sizeof  (double)                  !=  8)
    return 39;
  if (alignof (double)                  !=  8)
    return 40;
#ifdef HAVE_IA64_TYPES
  if (sizeof  (__float80)               != 16)
    return 41;
  if (alignof (__float80)               != 16)
    return 42;
  if (sizeof  (__float128)              != 16)
    return 43;
  if (alignof (__float128)              != 16)
    return 44;
#endif  /* HAVE_IA64_TYPES  */

  return 0;
}