OSDN Git Service

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