Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/20000223-1.c

raw
1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2 Contributed by Nathan Sidwell 23 Feb 2000 <[email protected]> */
3
4 /* __alignof__ should never return a non-power of 2
5 eg, sizeof(long double) might be 12, but that means it must be alignable
6 on a 4 byte boundary. */
7
8 void abort (void);
9
10 void check (char const *type, int align)
11 {
12 if ((align & -align) != align)
13 {
14 abort ();
15 }
16 }
17
18 #define QUOTE_(s) #s
19 #define QUOTE(s) QUOTE_(s)
20
21 #define check(t) check(QUOTE(t), __alignof__(t))
22
23 // This struct should have an alignment of the lcm of all the types. If one of
24 // the base alignments is not a power of two, then A cannot be power of two
25 // aligned.
26 struct A
27 {
28 char c;
29 signed short ss;
30 unsigned short us;
31 signed int si;
32 unsigned int ui;
33 signed long sl;
34 unsigned long ul;
35 signed long long sll;
36 unsigned long long ull;
37 float f;
38 double d;
39 long double ld;
40 void *dp;
41 void (*fp)();
42 };
43
44 int main ()
45 {
46 check (void);
47 check (char);
48 check (signed short);
49 check (unsigned short);
50 check (signed int);
51 check (unsigned int);
52 check (signed long);
53 check (unsigned long);
54 check (signed long long);
55 check (unsigned long long);
56 check (float);
57 check (double);
58 check (long double);
59 check (void *);
60 check (void (*)());
61 check (struct A);
62 return 0;
63 }