]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
[APX CCMP] Use ctestcc when comparing to const 0
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-attribute.C
1 // { dg-do compile { target c++11 } }
2
3 //A few constexpr's
4 constexpr int foo() { return __alignof__(int); }
5
6 template<typename T>
7 constexpr int fooT() { return __alignof__(T); }
8
9 template<int N>
10 constexpr int fooN() { return N; }
11
12 //Now the attributes
13
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)>())));
18
19 //with variables inside a template,
20 template <typename T>
21 void fun()
22 {
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)>())));
28 }
29
30 //instantiate it,
31 void bar()
32 {
33 fun<int>();
34 }
35
36 //with classes
37 struct __attribute__((aligned(foo()))) S0
38 {
39 char dummy;
40 };
41 S0 s0;
42
43 struct __attribute__((aligned(fooT<int>()))) S1
44 {
45 char dummy;
46 };
47 S1 s1;
48
49 //and class templates
50 template <typename T>
51 struct __attribute__((aligned(foo()))) S2
52 {
53 char dummy;
54 };
55
56 S2<int> s2;
57
58 template <typename T>
59 struct __attribute__((aligned(fooT<T>()))) S3
60 {
61 char dummy;
62 };
63 S3<int> s3;