Debian Codegraph @

clang/test/Parser/cxx0x-attributes.cpp

raw
1 // RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
2
3 // Need std::initializer_list
4 namespace std {
5 typedef decltype(sizeof(int)) size_t;
6
7 // libc++'s implementation
8 template <class _E>
9 class initializer_list
10 {
11 const _E* __begin_;
12 size_t __size_;
13
14 initializer_list(const _E* __b, size_t __s)
15 : __begin_(__b),
16 __size_(__s)
17 {}
18
19 public:
20 typedef _E value_type;
21 typedef const _E& reference;
22 typedef const _E& const_reference;
23 typedef size_t size_type;
24
25 typedef const _E* iterator;
26 typedef const _E* const_iterator;
27
28 initializer_list() : __begin_(nullptr), __size_(0) {}
29
30 size_t size() const {return __size_;}
31 const _E* begin() const {return __begin_;}
32 const _E* end() const {return __begin_ + __size_;}
33 };
34 }
35
36
37 // Declaration syntax checks
38 [[]] int before_attr;
39 int [[]] between_attr;
40 const [[]] int between_attr_2 = 0; // expected-error {{an attribute list cannot appear here}}
41 int after_attr [[]];
42 int * [[]] ptr_attr;
43 int & [[]] ref_attr = after_attr;
44 int & [[unknown]] ref_attr_2 = after_attr; // expected-warning {{unknown attribute 'unknown' ignored}}
45 int & [[noreturn]] ref_attr_3 = after_attr; // expected-error {{'noreturn' attribute cannot be applied to types}}
46 int && [[]] rref_attr = 0;
47 int array_attr [1] [[]];
48 alignas(8) int aligned_attr;
49 [[test::valid(for 42 [very] **** '+' symbols went on a trip and had a "good"_time; the end.)]] int garbage_attr; // expected-warning {{unknown attribute 'test::valid' ignored}}
50 [[,,,static, class, namespace,, inline, constexpr, mutable,, bitand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr; // expected-warning {{unknown attribute 'static' ignored}} \
51 // expected-warning {{unknown attribute 'class' ignored}} \
52 // expected-warning {{unknown attribute 'namespace' ignored}} \
53 // expected-warning {{unknown attribute 'inline' ignored}} \
54 // expected-warning {{unknown attribute 'constexpr' ignored}} \
55 // expected-warning {{unknown attribute 'mutable' ignored}} \
56 // expected-warning {{unknown attribute 'bitand' ignored}} \
57 // expected-warning {{unknown attribute 'bitor::compl' ignored}}
58 [[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
59 void fn_attr () [[]];
60 void noexcept_fn_attr () noexcept [[]];
61 struct MemberFnOrder {
62 virtual void f() const volatile && noexcept [[]] final = 0;
63 };
64 struct [[]] struct_attr;
65 class [[]] class_attr {};
66 union [[]] union_attr;
67 enum [[]] E { };
68 namespace test_misplacement {
69 [[]] struct struct_attr2; //expected-error{{misplaced attributes}}
70 [[]] class class_attr2; //expected-error{{misplaced attributes}}
71 [[]] union union_attr2; //expected-error{{misplaced attributes}}
72 [[]] enum E2 { }; //expected-error{{misplaced attributes}}
73 }
74
75 __attribute__(()) alignas(int) int xx; // expected-none
76 __attribute__(()) alignas(int) [[]] int yy; // expected-none
77 [[]] __attribute__(()) alignas(int) int zz; // expected-none
78 alignas(int) [[]] __attribute__(()) int aa; // expected-none
79 [[]] alignas(int) __attribute__(()) int bb; // expected-none
80 __attribute__(()) [[]] alignas(int) int cc; // expected-none
81
82 class C1 {
83 __attribute__(()) alignas(int) int x; // expected-none
84 __attribute__(()) alignas(int) [[]] int y; // expected-none
85 [[]] __attribute__(()) alignas(int) int z; // expected-none
86 alignas(int) [[]] __attribute__(()) int a; // expected-none
87 [[]] alignas(int) __attribute__(()) int b; // expected-none
88 __attribute__(()) [[]] alignas(int) int c; // expected-none
89 };
90
91 void fn_with_decl() {
92 __attribute__(()) alignas(int) int x; // expected-none
93 __attribute__(()) alignas(int) [[]] int y; // expected-none
94 [[]] __attribute__(()) alignas(int) int z; // expected-none
95 alignas(int) [[]] __attribute__(()) int a; // expected-none
96 [[]] alignas(int) __attribute__(()) int b; // expected-none
97 __attribute__(()) [[]] alignas(int) int c; // expected-none
98 }
99 // Checks attributes placed at wrong syntactic locations of class specifiers.
100 class [[]] [[]]
101 attr_after_class_name_decl [[]] [[]]; // expected-error {{an attribute list cannot appear here}}
102
103 class [[]] [[]]
104 attr_after_class_name_definition [[]] [[]] [[]]{}; // expected-error {{an attribute list cannot appear here}}
105
106 class [[]] c {};
107 class c [[]] [[]] x;
108 class c [[]] [[]] y [[]] [[]];
109 class c final [(int){0}];
110
111 class base {};
112 class [[]] [[]] final_class
113 alignas(float) [[]] final // expected-error {{an attribute list cannot appear here}}
114 alignas(float) [[]] [[]] alignas(float): base{}; // expected-error {{an attribute list cannot appear here}}
115
116 class [[]] [[]] final_class_another
117 [[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}}
118 [[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}}
119
120 // The diagnostics here don't matter much, this just shouldn't crash:
121 class C final [[deprecated(l]] {}); //expected-error {{expected string literal as argument of 'deprecated' attribute}} expected-error {{an attribute list cannot appear here}} expected-error {{expected unqualified-id}}
122 class D final alignas ([l) {}]{}); // expected-error {{expected ',' or ']' in lambda capture list}} expected-error {{an attribute list cannot appear here}}
123
124 [[]] struct with_init_declarators {} init_declarator;
125 [[]] struct no_init_declarators; // expected-error {{misplaced attributes}}
126 template<typename> [[]] struct no_init_declarators_template; // expected-error {{an attribute list cannot appear here}}
127 void fn_with_structs() {
128 [[]] struct with_init_declarators {} init_declarator;
129 [[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}}
130 }
131 [[]];
132 struct ctordtor {
133 [[]] ctordtor [[]] () [[]];
134 ctordtor (C) [[]];
135 [[]] ~ctordtor [[]] () [[]];
136 };
137 [[]] ctordtor::ctordtor [[]] () [[]] {}
138 [[]] ctordtor::ctordtor (C) [[]] try {} catch (...) {}
139 [[]] ctordtor::~ctordtor [[]] () [[]] {}
140 extern "C++" [[]] int extern_attr;
141 template <typename T> [[]] void template_attr ();
142 [[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
143
144 int comma_attr [[,]];
145 int scope_attr [[foo::]]; // expected-error {{expected identifier}}
146 int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}}
147 unsigned [[]] int attr_in_decl_spec; // expected-error {{an attribute list cannot appear here}}
148 unsigned [[]] int [[]] const double_decl_spec = 0; // expected-error 2{{an attribute list cannot appear here}}
149 class foo {
150 void const_after_attr () [[]] const; // expected-error {{expected ';'}}
151 };
152 extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
153 [[]] extern "C++" { } // expected-error {{an attribute list cannot appear here}}
154 [[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
155 [[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
156 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
157 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
158
159 [[]] using ns::i;
160 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
161 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
162 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
163
164 using[[]] alignas(4)[[]] ns::i; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to variables, data members and tag types}} expected-warning {{ISO C++}}
165 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
166
167 void bad_attributes_in_do_while() {
168 do {} while (
169 [[ns::i); // expected-error {{expected ']'}} \
170 // expected-note {{to match this '['}} \
171 // expected-error {{expected expression}}
172 do {} while (
173 [[a]b ns::i); // expected-error {{expected ']'}} \
174 // expected-note {{to match this '['}} \
175 // expected-error {{expected expression}}
176 do {} while (
177 [[ab]ab] ns::i); // expected-error {{an attribute list cannot appear here}}
178 do {} while ( // expected-note {{to match this '('}}
179 alignas(4 ns::i; // expected-note {{to match this '('}}
180 // expected-error@-1 {{expected ';' after do/while}}
181 } // expected-error 2{{expected ')'}} expected-error {{expected expression}}
182
183 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
184 using T [[]] = int; // ok
185 template<typename T> using U [[]] = T;
186 using ns::i [[]];
187 using ns::i [[]], ns::i [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
188 struct using_in_struct_base {
189 typedef int i, j, k, l;
190 };
191 struct using_in_struct : using_in_struct_base {
192 [[]] using using_in_struct_base::i;
193 using using_in_struct_base::j [[]];
194 [[]] using using_in_struct_base::k [[]], using_in_struct_base::l [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
195 };
196 using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
197 using T [[unknown]] = int; // expected-warning {{unknown attribute 'unknown' ignored}}
198 using T [[noreturn]] = int; // expected-error {{'noreturn' attribute only applies to functions}}
199 using V = int; // expected-note {{previous}}
200 using V [[gnu::vector_size(16)]] = int; // expected-error {{redefinition with different types}}
201
202 auto trailing() -> [[]] const int; // expected-error {{an attribute list cannot appear here}}
203 auto trailing() -> const [[]] int; // expected-error {{an attribute list cannot appear here}}
204 auto trailing() -> const int [[]];
205 auto trailing_2() -> struct struct_attr [[]];
206
207 namespace N {
208 struct S {};
209 };
210 template<typename> struct Template {};
211
212 // FIXME: Improve this diagnostic
213 struct [[]] N::S s; // expected-error {{an attribute list cannot appear here}}
214 struct [[]] Template<int> t; // expected-error {{an attribute list cannot appear here}}
215 struct [[]] ::template Template<int> u; // expected-error {{an attribute list cannot appear here}}
216 template struct [[]] Template<char>; // expected-error {{an attribute list cannot appear here}}
217 template struct __attribute__((pure)) Template<std::size_t>; // We still allow GNU-style attributes here
218 template <> struct [[]] Template<void>;
219
220 enum [[]] E1 {};
221 enum [[]] E2; // expected-error {{forbids forward references}}
222 enum [[]] E1;
223 enum [[]] E3 : int;
224 enum [[]] {
225 k_123 [[]] = 123 // expected-warning {{attributes on an enumerator declaration are a C++17 extension}}
226 };
227 enum [[]] E1 e; // expected-error {{an attribute list cannot appear here}}
228 enum [[]] class E4 { }; // expected-error {{an attribute list cannot appear here}}
229 enum struct [[]] E5;
230
231 struct S {
232 friend int f [[]] (); // expected-FIXME{{an attribute list cannot appear here}}
233 friend int f1 [[noreturn]] (); //expected-error{{an attribute list cannot appear here}}
234 friend int f2 [[]] [[noreturn]] () {}
235 [[]] friend int g(); // expected-error{{an attribute list cannot appear here}}
236 [[]] friend int h() {
237 }
238 [[]] friend int f3(), f4(), f5(); // expected-error{{an attribute list cannot appear here}}
239 friend int f6 [[noreturn]] (), f7 [[noreturn]] (), f8 [[noreturn]] (); // expected-error3 {{an attribute list cannot appear here}}
240 friend class [[]] C; // expected-error{{an attribute list cannot appear here}}
241 [[]] friend class D; // expected-error{{an attribute list cannot appear here}}
242 [[]] friend int; // expected-error{{an attribute list cannot appear here}}
243 };
244 template<typename T> void tmpl(T) {}
245 template void tmpl [[]] (int); // expected-FIXME {{an attribute list cannot appear here}}
246 template [[]] void tmpl(char); // expected-error {{an attribute list cannot appear here}}
247 template void [[]] tmpl(short);
248
249 // Argument tests
250 alignas int aligned_no_params; // expected-error {{expected '('}}
251 alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
252
253 // Statement tests
254 void foo () {
255 [[]] ;
256 [[]] { }
257 [[]] if (0) { }
258 [[]] for (;;);
259 [[]] do {
260 [[]] continue;
261 } while (0);
262 [[]] while (0);
263
264 [[]] switch (i) {
265 [[]] case 0:
266 [[]] default:
267 [[]] break;
268 }
269
270 [[]] goto there;
271 [[]] there:
272
273 [[]] try {
274 } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
275 }
276 struct S { int arr[2]; } s;
277 (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
278 int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
279
280 void bar [[noreturn]] ([[]] int i, [[]] int j);
281 using FuncType = void ([[]] int);
282 void baz([[]]...); // expected-error {{expected parameter declarator}}
283
284 [[]] return;
285 }
286
287 template<typename...Ts> void variadic() {
288 void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
289 }
290
291 template <int... Is> void variadic_nttp() {
292 void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
293 void baz [[clang::no_sanitize(Is...)]] (); // expected-error {{expected string literal as argument of 'no_sanitize' attribute}}
294 void bor [[clang::annotate("A", "V" ...)]] (); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
295 void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // expected-error {{'clang::annotate' attribute requires parameter 1 to be a constant expression}} expected-note {{subexpression not valid in a constant expression}}
296 void boo [[unknown::foo(Is...)]] (); // expected-warning {{unknown attribute 'unknown::foo' ignored}}
297 void faz [[clang::annotate("C", (Is + ...))]] (); // expected-warning {{pack fold expression is a C++17 extension}}
298 void far [[clang::annotate("D", Is...)]] ();
299 void foz [[clang::annotate("E", 1, 2, 3, Is...)]] ();
300 void fiz [[clang::annotate("F", Is..., 1, 2, 3)]] ();
301 void fir [[clang::annotate("G", 1, Is..., 2, 3)]] ();
302 }
303
304 // Expression tests
305 void bar () {
306 // FIXME: GCC accepts [[gnu::noreturn]] on a lambda, even though it appertains
307 // to the operator()'s type, and GCC does not otherwise accept attributes
308 // applied to types. Use that to test this.
309 [] () [[gnu::noreturn]] { return; } (); // expected-warning {{attribute 'gnu::noreturn' ignored}} FIXME-error {{should not return}}
310 [] () [[gnu::noreturn]] { throw; } (); // expected-warning {{attribute 'gnu::noreturn' ignored}}
311 new int[42][[]][5][[]]{};
312 }
313
314 // Condition tests
315 void baz () {
316 if ([[unknown]] bool b = true) { // expected-warning {{unknown attribute 'unknown' ignored}}
317 switch ([[unknown]] int n { 42 }) { // expected-warning {{unknown attribute 'unknown' ignored}}
318 default:
319 for ([[unknown]] int n = 0; [[unknown]] char b = n < 5; ++b) { // expected-warning 2{{unknown attribute 'unknown' ignored}}
320 }
321 }
322 }
323 int x;
324 // An attribute can be applied to an expression-statement, such as the first
325 // statement in a for. But it can't be applied to a condition which is an
326 // expression.
327 for ([[]] x = 0; ; ) {} // expected-error {{an attribute list cannot appear here}}
328 for (; [[]] x < 5; ) {} // expected-error {{an attribute list cannot appear here}}
329 while ([[]] bool k { false }) {
330 }
331 while ([[]] true) { // expected-error {{an attribute list cannot appear here}}
332 }
333 do {
334 } while ([[]] false); // expected-error {{an attribute list cannot appear here}}
335
336 for ([[unknown]] int n : { 1, 2, 3 }) { // expected-warning {{unknown attribute 'unknown' ignored}}
337 }
338 }
339
340 enum class __attribute__((visibility("hidden"))) SecretKeepers {
341 one, /* rest are deprecated */ two, three
342 };
343 enum class [[]] EvenMoreSecrets {};
344
345 namespace arguments {
346 void f[[gnu::format(printf, 1, 2)]](const char*, ...);
347 void g() [[unknown::foo(ignore arguments for unknown attributes, even with symbols!)]]; // expected-warning {{unknown attribute 'unknown::foo' ignored}}
348 [[deprecated("with argument")]] int i;
349 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
350 }
351
352 // Forbid attributes on decl specifiers.
353 unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-error {{'gnu::unused' attribute cannot be applied to types}} \
354 expected-error {{an attribute list cannot appear here}}
355 typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-error {{'gnu::unused' attribute cannot be applied to types}} \
356 expected-error {{an attribute list cannot appear here}}
357 int [[carries_dependency]] foo(int [[carries_dependency]] x); // expected-error 2{{'carries_dependency' attribute cannot be applied to types}}
358
359 // Forbid [[gnu::...]] attributes on declarator chunks.
360 int *[[gnu::unused]] v3; // expected-warning {{attribute 'gnu::unused' ignored}}
361 int v4[2][[gnu::unused]]; // expected-warning {{attribute 'gnu::unused' ignored}}
362 int v5()[[gnu::unused]]; // expected-warning {{attribute 'gnu::unused' ignored}}
363
364 [[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}}
365 [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}}
366 [[carries_dependency]]; // expected-error {{'carries_dependency' attribute only applies to parameters, Objective-C methods, and functions}}
367
368 class A {
369 A([[gnu::unused]] int a);
370 };
371 A::A([[gnu::unused]] int a) {}
372
373 namespace GccConst {
374 // GCC's tokenizer treats const and __const as the same token.
375 [[gnu::const]] int *f1();
376 [[gnu::__const]] int *f2();
377 [[gnu::__const__]] int *f3();
378 void f(const int *);
379 void g() { f(f1()); f(f2()); }
380 void h() { f(f3()); }
381 }
382
383 namespace GccASan {
384 __attribute__((no_address_safety_analysis)) void f1();
385 __attribute__((no_sanitize_address)) void f2();
386 [[gnu::no_address_safety_analysis]] void f3();
387 [[gnu::no_sanitize_address]] void f4();
388 }
389
390 namespace {
391 [[deprecated]] void bar();
392 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
393 [[deprecated("hello")]] void baz();
394 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
395 [[deprecated()]] void foo();
396 // expected-error@-1 {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
397 [[gnu::deprecated()]] void quux();
398 }
399
400 namespace {
401 [[ // expected-error {{expected ']'}}
402 #pragma pack(pop)
403 deprecated
404 ]] void bad();
405 }
406
407 int fallthru(int n) {
408 switch (n) {
409 case 0:
410 n += 5;
411 [[fallthrough]]; // expected-warning {{use of the 'fallthrough' attribute is a C++17 extension}}
412 case 1:
413 n *= 2;
414 break;
415 }
416 return n;
417 }
418
419 template<typename T> struct TemplateStruct {};
420 class FriendClassesWithAttributes {
421 // We allow GNU-style attributes here
422 template <class _Tp, class _Alloc> friend class __attribute__((__type_visibility__("default"))) vector;
423 template <class _Tp, class _Alloc> friend class __declspec(code_seg("foo,whatever")) vector2;
424 // But not C++11 ones
425 template <class _Tp, class _Alloc> friend class[[]] vector3; // expected-error {{an attribute list cannot appear here}}
426 template <class _Tp, class _Alloc> friend class [[clang::__type_visibility__(("default"))]] vector4; // expected-error {{an attribute list cannot appear here}}
427
428 // Also allowed
429 friend struct __attribute__((__type_visibility__("default"))) TemplateStruct<FriendClassesWithAttributes>;
430 friend struct __declspec(code_seg("foo,whatever")) TemplateStruct<FriendClassesWithAttributes>;
431 friend struct[[]] TemplateStruct<FriendClassesWithAttributes>; // expected-error {{an attribute list cannot appear here}}
432 friend struct [[clang::__type_visibility__("default")]] TemplateStruct<FriendClassesWithAttributes>; // expected-error {{an attribute list cannot appear here}}
433 };
434
435 #define attr_name bitand
436 #define attr_name_2(x) x
437 #define attr_name_3(x, y) x##y
438 [[attr_name, attr_name_2(bitor), attr_name_3(com, pl)]] int macro_attrs; // expected-warning {{unknown attribute 'compl' ignored}} \
439 expected-warning {{unknown attribute 'bitor' ignored}} \
440 expected-warning {{unknown attribute 'bitand' ignored}}
441
442 // Check that we can parse an attribute in our vendor namespace.
443 [[clang::annotate("test")]] void annotate1();
444 [[_Clang::annotate("test")]] void annotate2();
445 // Note: __clang__ is a predefined macro, which is why _Clang is the
446 // prefered "protected" vendor namespace. We support __clang__ only for
447 // people expecting it to behave the same as __gnu__.
448 [[__clang__::annotate("test")]] void annotate3(); // expected-warning {{'__clang__' is a predefined macro name, not an attribute scope specifier; did you mean '_Clang' instead?}}
449
450 // Check ordering: C++11 attributes must appear before GNU attributes.
451 class Ordering {
452 void f1(
453 int ([[]] __attribute__(()) int n)
454 ) {
455 }
456
457 void f2(
458 int (*)([[]] __attribute__(()) int n)
459 ) {
460 }
461
462 void f3(
463 int (__attribute__(()) [[]] int n) // expected-error {{an attribute list cannot appear here}}
464 ) {
465 }
466
467 void f4(
468 int (*)(__attribute__(()) [[]] int n) // expected-error {{an attribute list cannot appear here}}
469 ) {
470 }
471 };
472
473 namespace P2361 {
474 [[deprecated(L"abc")]] void a(); // expected-warning{{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}} \
475 // expected-warning {{use of the 'deprecated' attribute is a C++14 extension}}
476 [[nodiscard("\123")]] int b(); // expected-error{{invalid escape sequence '\123' in an unevaluated string literal}}
477 }
478
479 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced attributes; expected attributes here}}