2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-attribute.C
blobcda0e926bf7b4ac7bf2dae416ecdb80094f26e0b
1 // { dg-do compile { target c++11 } }
3 //A few constexpr's
4 constexpr int foo() { return __alignof__(int); }
6 template<typename T>
7 constexpr int fooT() { return __alignof__(T); }
9 template<int N>
10 constexpr int fooN() { return N; }
12 //Now the attributes
14 //with normal variables,
15 int a __attribute__((aligned(foo())));
16 int b __attribute__((aligned(fooT<int>())));
17 int c __attribute__((aligned(fooN<__alignof__(int)>())));
19 //with variables inside a template,
20 template <typename T>
21 void fun()
23     T a __attribute__((aligned(foo())));
24     T b __attribute__((aligned(fooT<T>())));
25     T c __attribute__((aligned(fooN<__alignof__(T)>())));
26     T d __attribute__((aligned(fooT<int>())));
27     T e __attribute__((aligned(fooN<__alignof__(int)>())));
30 //instantiate it,
31 void bar()
33     fun<int>();
36 //with classes
37 struct __attribute__((aligned(foo()))) S0
39     char dummy;
41 S0 s0;
43 struct __attribute__((aligned(fooT<int>()))) S1
45     char dummy;
47 S1 s1;
49 //and class templates
50 template <typename T>
51 struct __attribute__((aligned(foo()))) S2
53     char dummy;
56 S2<int> s2;
58 template <typename T>
59 struct __attribute__((aligned(fooT<T>()))) S3
61     char dummy;
63 S3<int> s3;