Merged with mainline at revision 128810.
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / aligned_storage / value.cc
blob2ea6fee4956c8bd5a73a7713011f21bf964e432e
1 // { dg-options "-std=gnu++0x" }
2 // 2007-09-17 Paolo Carlini <pcarlini@suse.de>
3 //
4 // Copyright (C) 2007 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 #include <type_traits>
23 #include <testsuite_hooks.h>
24 #include <testsuite_tr1.h>
26 struct MSAlignType { } __attribute__((__aligned__));
28 void test01()
30 bool test __attribute__((unused)) = true;
31 using std::aligned_storage;
32 using std::alignment_of;
33 using namespace __gnu_test;
35 const std::size_t align_c = alignment_of<char>::value;
36 VERIFY( (sizeof(aligned_storage<4, align_c>::type) >= 4) );
37 VERIFY( (__alignof__(aligned_storage<4, align_c>::type) == align_c) );
39 const std::size_t align_s = alignment_of<short>::value;
40 VERIFY( (sizeof(aligned_storage<1, align_s>::type) >= 1) );
41 VERIFY( (__alignof__(aligned_storage<1, align_s>::type) == align_s) );
43 const std::size_t align_i = alignment_of<int>::value;
44 VERIFY( (sizeof(aligned_storage<7, align_i>::type) >= 7) );
45 VERIFY( (__alignof__(aligned_storage<7, align_i>::type) == align_i) );
47 const std::size_t align_d = alignment_of<double>::value;
48 VERIFY( (sizeof(aligned_storage<2, align_d>::type) >= 2) );
49 VERIFY( (__alignof__(aligned_storage<2, align_d>::type) == align_d) );
51 const std::size_t align_ai = alignment_of<int[4]>::value;
52 VERIFY( (sizeof(aligned_storage<20, align_ai>::type) >= 20) );
53 VERIFY( (__alignof__(aligned_storage<20, align_ai>::type) == align_ai) );
55 const std::size_t align_ct = alignment_of<ClassType>::value;
56 VERIFY( (sizeof(aligned_storage<11, align_ct>::type) >= 11) );
57 VERIFY( (__alignof__(aligned_storage<11, align_ct>::type) == align_ct) );
59 const std::size_t align_msa = alignment_of<MSAlignType>::value;
60 VERIFY( (sizeof(aligned_storage<5>::type) >= 5) );
61 VERIFY( (__alignof__(aligned_storage<5>::type) == align_msa) );
64 int main()
66 test01();
67 return 0;