]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C
AArch64: Improve costing of ctz
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-attribute.C
CommitLineData
4b2e63de 1// { dg-do compile { target c++11 } }
437697b8
RRC
2
3//A few constexpr's
4constexpr int foo() { return __alignof__(int); }
5
6template<typename T>
7constexpr int fooT() { return __alignof__(T); }
8
9template<int N>
10constexpr int fooN() { return N; }
11
12//Now the attributes
13
14//with normal variables,
15int a __attribute__((aligned(foo())));
16int b __attribute__((aligned(fooT<int>())));
17int c __attribute__((aligned(fooN<__alignof__(int)>())));
18
19//with variables inside a template,
20template <typename T>
21void 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,
31void bar()
32{
33 fun<int>();
34}
35
36//with classes
37struct __attribute__((aligned(foo()))) S0
38{
39 char dummy;
40};
41S0 s0;
42
43struct __attribute__((aligned(fooT<int>()))) S1
44{
45 char dummy;
46};
47S1 s1;
48
49//and class templates
50template <typename T>
51struct __attribute__((aligned(foo()))) S2
52{
53 char dummy;
54};
55
56S2<int> s2;
57
58template <typename T>
59struct __attribute__((aligned(fooT<T>()))) S3
60{
61 char dummy;
62};
63S3<int> s3;