1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 |
2 | // expected-no-diagnostics |
3 | |
4 | // Test that the alignment of a empty direct base class is correctly |
5 | // inherited by the derived class. |
6 | |
7 | struct A { |
8 | } __attribute__ ((aligned(16))); |
9 | |
10 | static_assert(__alignof(A) == 16, "A should be aligned to 16 bytes"); |
11 | |
12 | struct B1 : public A { |
13 | }; |
14 | |
15 | static_assert(__alignof(B1) == 16, "B1 should be aligned to 16 bytes"); |
16 | |
17 | struct B2 : public A { |
18 | } __attribute__ ((aligned(2))); |
19 | |
20 | static_assert(__alignof(B2) == 16, "B2 should be aligned to 16 bytes"); |
21 | |
22 | struct B3 : public A { |
23 | } __attribute__ ((aligned(4))); |
24 | |
25 | static_assert(__alignof(B3) == 16, "B3 should be aligned to 16 bytes"); |
26 | |
27 | struct B4 : public A { |
28 | } __attribute__ ((aligned(8))); |
29 | |
30 | static_assert(__alignof(B4) == 16, "B4 should be aligned to 16 bytes"); |
31 | |
32 | struct B5 : public A { |
33 | } __attribute__ ((aligned(16))); |
34 | |
35 | static_assert(__alignof(B5) == 16, "B5 should be aligned to 16 bytes"); |
36 | |
37 | struct B6 : public A { |
38 | } __attribute__ ((aligned(32))); |
39 | |
40 | static_assert(__alignof(B6) == 32, "B6 should be aligned to 32 bytes"); |
41 | |
42 | |