1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -pedantic -std=c++11 %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc int align_illegal alignas(3); //expected-error {{requested alignment is not a power of 2}}
4f4a2713aSLionel Sambuc char align_big alignas(int);
5f4a2713aSLionel Sambuc int align_small alignas(1); // expected-error {{requested alignment is less than minimum}}
6f4a2713aSLionel Sambuc int align_multiple alignas(1) alignas(8) alignas(1);
7f4a2713aSLionel Sambuc alignas(4) int align_before;
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc struct align_member {
10f4a2713aSLionel Sambuc   int member alignas(8);
11f4a2713aSLionel Sambuc   int bitfield alignas(1) : 1; // expected-error {{}}
12f4a2713aSLionel Sambuc };
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc void f(alignas(1) char c) { // expected-error {{'alignas' attribute cannot be applied to a function parameter}}
15f4a2713aSLionel Sambuc   alignas(1) register char k; // expected-error {{'alignas' attribute cannot be applied to a variable with 'register' storage class}} expected-warning {{deprecated}}
16f4a2713aSLionel Sambuc   try {
17f4a2713aSLionel Sambuc   } catch (alignas(4) int n) { // expected-error {{'alignas' attribute cannot be applied to a 'catch' variable}}
18f4a2713aSLionel Sambuc   }
19f4a2713aSLionel Sambuc }
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc template <unsigned A> struct alignas(A) align_class_template {};
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc template <typename... T> struct alignas(T...) align_class_temp_pack_type {};
25f4a2713aSLionel Sambuc template <unsigned... A> struct alignas(A...) align_class_temp_pack_expr {};
26f4a2713aSLionel Sambuc struct alignas(int...) alignas_expansion_no_packs {}; // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
27f4a2713aSLionel Sambuc template <typename... A> struct outer {
28f4a2713aSLionel Sambuc   template <typename... B> struct alignas(alignof(A) * alignof(B)...) inner {};
29f4a2713aSLionel Sambuc   // expected-error@-1 {{pack expansion contains parameter packs 'A' and 'B' that have different lengths (1 vs. 2)}}
30f4a2713aSLionel Sambuc };
31f4a2713aSLionel Sambuc outer<int>::inner<short, double> mismatched_packs; // expected-note {{in instantiation of}}
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc typedef char align_typedef alignas(8); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}}
34f4a2713aSLionel Sambuc template<typename T> using align_alias_template = align_typedef alignas(8); // expected-error {{'alignas' attribute cannot be applied to types}}
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}}
37f4a2713aSLionel Sambuc static_assert(alignof(align_small) == 1, "j's alignment is wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}}
38f4a2713aSLionel Sambuc static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}}
39f4a2713aSLionel Sambuc static_assert(alignof(align_member) == 8, "quuux's alignment is wrong");
40f4a2713aSLionel Sambuc static_assert(sizeof(align_member) == 8, "quuux's size is wrong");
41f4a2713aSLionel Sambuc static_assert(alignof(align_class_template<8>) == 8, "template's alignment is wrong");
42f4a2713aSLionel Sambuc static_assert(alignof(align_class_template<16>) == 16, "template's alignment is wrong");
43f4a2713aSLionel Sambuc static_assert(alignof(align_class_temp_pack_type<short, int, long>) == alignof(long), "template's alignment is wrong");
44f4a2713aSLionel Sambuc static_assert(alignof(align_class_temp_pack_expr<8, 16, 32>) == 32, "template's alignment is wrong");
45f4a2713aSLionel Sambuc static_assert(alignof(outer<int,char>::inner<double,short>) == alignof(int) * alignof(double), "template's alignment is wrong");
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc static_assert(alignof(int(int)) >= 1, "alignof(function) not positive"); // expected-error{{invalid application of 'alignof' to a function type}}
48*0a6a1f1dSLionel Sambuc 
49*0a6a1f1dSLionel Sambuc [[__carries_dependency__]]  // expected-warning{{unknown attribute '__carries_dependency__' ignored}}
50*0a6a1f1dSLionel Sambuc void func(void);
51*0a6a1f1dSLionel Sambuc 
52*0a6a1f1dSLionel Sambuc alignas(4) auto PR19252 = 0;
53