1 // RUN: %clang_cc1 -std=c++11 -triple i386-apple-darwin9 -fsyntax-only -verify %s
2 // expected-no-diagnostics
4 using size_t = decltype(sizeof(0));
6 struct complex_double
{
11 template <typename T
, size_t ABI
, size_t Preferred
>
12 struct check_alignment
{
16 static_assert(__alignof__(value
) == Preferred
, "__alignof__(value) != Preferred");
17 static_assert(__alignof__(type
) == Preferred
, "__alignof__(type) != Preferred");
18 static_assert(alignof(type
) == ABI
, "alignof(type) != ABI");
22 template struct check_alignment
<double, 4, 8>;
23 template struct check_alignment
<long long, 4, 8>;
24 template struct check_alignment
<unsigned long long, 4, 8>;
25 template struct check_alignment
<complex_double
, 4, 4>;
28 struct __attribute__((packed
))
32 template struct check_alignment
<packed_struct
, 1, 1>;
33 static_assert(__alignof__(g_packedstruct
.a
) == 1, "__alignof__(packed_struct.member) != 1");
35 template struct check_alignment
<double[3], 4, 8>;
37 enum big_enum
{ x
= 18446744073709551615ULL };
38 template struct check_alignment
<big_enum
, 4, 8>;
42 #define ALIGNED(x) __attribute__((aligned(x)))
44 typedef ALIGNED(2) struct {
46 } aligned_before_struct
;
48 static_assert(sizeof(aligned_before_struct
) == 3, "");
49 static_assert(sizeof(aligned_before_struct
[1]) == 4, "");
50 static_assert(sizeof(aligned_before_struct
[2]) == 6, "");
51 static_assert(sizeof(aligned_before_struct
[2][1]) == 8, "");
52 static_assert(sizeof(aligned_before_struct
[1][2]) == 6, "");
54 typedef struct ALIGNED(2) {
56 } aligned_after_struct
;
58 static_assert(sizeof(aligned_after_struct
) == 4, "");
59 static_assert(sizeof(aligned_after_struct
[1]) == 4, "");
60 static_assert(sizeof(aligned_after_struct
[2]) == 8, "");
61 static_assert(sizeof(aligned_after_struct
[2][1]) == 8, "");
62 static_assert(sizeof(aligned_after_struct
[1][2]) == 8, "");