[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / alignas.cpp
blob680f07b32998f0ee06ca87d679e867d4af95011e
1 // RUN: %clang_cc1 -std=c++11 -verify %s
3 // expected-no-diagnostics
4 using size_t = decltype(sizeof(0));
6 template<typename T, typename U>
7 constexpr T max(T t, U u) { return t > u ? t : u; }
9 template<typename T, typename ...Ts>
10 constexpr auto max(T t, Ts ...ts) -> decltype(max(t, max(ts...))) {
11 return max(t, max(ts...));
14 template<typename...T> struct my_union {
15 alignas(T...) char buffer[max(sizeof(T)...)];
18 struct alignas(8) A { char c; };
19 struct alignas(4) B { short s; };
20 struct C { char a[16]; };
22 static_assert(sizeof(my_union<A, B, C>) == 16, "");
23 static_assert(alignof(my_union<A, B, C>) == 8, "");
25 namespace PR35028 {
26 template<class X, int Alignment> struct alignas(X) alignas(long long) alignas(long double) alignas(Alignment) Aligned {
27 union {
28 long long align1;
29 long double align2;
30 char data[sizeof(X)];
33 Aligned<int, 1> a;