blob: 906d72b087cb56283acb0175f4aec63535cd1848 [file] [log] [blame]
Richard Smith4f902c72016-03-08 00:32:55 +00001// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++1z-extensions %s
Alexis Hunt96d5c762009-11-21 08:43:09 +00002
Alexis Hunt6aa9bee2012-06-23 05:07:58 +00003// Need std::initializer_list
4namespace 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
Alexis Hunt96d5c762009-11-21 08:43:09 +000037// Declaration syntax checks
38[[]] int before_attr;
Peter Collingbourne70188b32011-09-29 18:03:57 +000039int [[]] between_attr;
Alexis Hunt6aa9bee2012-06-23 05:07:58 +000040const [[]] int between_attr_2 = 0; // expected-error {{an attribute list cannot appear here}}
Alexis Hunt96d5c762009-11-21 08:43:09 +000041int after_attr [[]];
42int * [[]] ptr_attr;
Richard Smith7bdcc4a2012-04-10 01:32:12 +000043int & [[]] ref_attr = after_attr;
Richard Smith54ecd982013-02-20 19:22:51 +000044int & [[unknown]] ref_attr_2 = after_attr; // expected-warning {{unknown attribute 'unknown' ignored}}
45int & [[noreturn]] ref_attr_3 = after_attr; // expected-error {{'noreturn' attribute cannot be applied to types}}
Richard Smith7bdcc4a2012-04-10 01:32:12 +000046int && [[]] rref_attr = 0;
Alexis Hunt96d5c762009-11-21 08:43:09 +000047int array_attr [1] [[]];
Peter Collingbourne2f3cf4b2011-09-29 18:04:28 +000048alignas(8) int aligned_attr;
Michael Han23214e52012-10-03 01:56:22 +000049[[test::valid(for 42 [very] **** '+' symbols went on a trip and had a "good"_time; the end.)]] int garbage_attr; // expected-warning {{unknown attribute '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}} \
Aaron Ballmanb8e20392014-03-31 17:32:39 +000051 // 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 'compl' ignored}}
Richard Smith3dff2512012-04-10 03:25:07 +000058[[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
Alexis Hunt96d5c762009-11-21 08:43:09 +000059void fn_attr () [[]];
Richard Smith7bdcc4a2012-04-10 01:32:12 +000060void noexcept_fn_attr () noexcept [[]];
61struct MemberFnOrder {
62 virtual void f() const volatile && noexcept [[]] final = 0;
63};
Alexis Hunt6aa9bee2012-06-23 05:07:58 +000064struct [[]] struct_attr;
Alexis Hunt96d5c762009-11-21 08:43:09 +000065class [[]] class_attr {};
Alexis Hunt6aa9bee2012-06-23 05:07:58 +000066union [[]] union_attr;
Michael Han9407e502012-11-26 22:54:45 +000067
68// Checks attributes placed at wrong syntactic locations of class specifiers.
Michael Han9407e502012-11-26 22:54:45 +000069class [[]] [[]]
70 attr_after_class_name_decl [[]] [[]]; // expected-error {{an attribute list cannot appear here}}
71
72class [[]] [[]]
73 attr_after_class_name_definition [[]] [[]] [[]]{}; // expected-error {{an attribute list cannot appear here}}
74
75class [[]] c {};
76class c [[]] [[]] x;
77class c [[]] [[]] y [[]] [[]];
78class c final [(int){0}];
79
80class base {};
Aaron Ballman3a8e2d92013-11-27 18:53:58 +000081class [[]] [[]] final_class
Michael Han9407e502012-11-26 22:54:45 +000082 alignas(float) [[]] final // expected-error {{an attribute list cannot appear here}}
83 alignas(float) [[]] [[]] alignas(float): base{}; // expected-error {{an attribute list cannot appear here}}
84
Aaron Ballman3a8e2d92013-11-27 18:53:58 +000085class [[]] [[]] final_class_another
Michael Han9407e502012-11-26 22:54:45 +000086 [[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}}
87 [[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}}
88
Nico Weber36de3a22014-12-29 21:56:22 +000089// The diagnostics here don't matter much, this just shouldn't crash:
90class C final [[deprecated(l]] {}); // expected-error {{use of undeclared identifier}} expected-error {{expected ']'}} expected-error {{an attribute list cannot appear here}} expected-error {{expected unqualified-id}}
91class D final alignas ([l) {}]{}); // expected-error {{expected ',' or ']' in lambda capture list}} expected-error {{an attribute list cannot appear here}}
92
Alexis Hunt6aa9bee2012-06-23 05:07:58 +000093[[]] struct with_init_declarators {} init_declarator;
94[[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}}
Richard Smith2386c8b2013-02-22 09:06:26 +000095template<typename> [[]] struct no_init_declarators_template; // expected-error {{an attribute list cannot appear here}}
96void fn_with_structs() {
97 [[]] struct with_init_declarators {} init_declarator;
98 [[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}}
99}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000100[[]];
101struct ctordtor {
102 [[]] ctordtor();
103 [[]] ~ctordtor();
104};
105[[]] ctordtor::ctordtor() {}
106[[]] ctordtor::~ctordtor() {}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000107extern "C++" [[]] int extern_attr;
108template <typename T> [[]] void template_attr ();
Peter Collingbourne49eedec2011-09-29 18:04:05 +0000109[[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
Alexis Hunt96d5c762009-11-21 08:43:09 +0000110
Richard Smith3dff2512012-04-10 03:25:07 +0000111int comma_attr [[,]];
Alexis Hunt96d5c762009-11-21 08:43:09 +0000112int scope_attr [[foo::]]; // expected-error {{expected identifier}}
Richard Smith7bdcc4a2012-04-10 01:32:12 +0000113int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000114unsigned [[]] int attr_in_decl_spec; // expected-error {{an attribute list cannot appear here}}
115unsigned [[]] int [[]] const double_decl_spec = 0; // expected-error 2{{an attribute list cannot appear here}}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000116class foo {
Richard Smith7bdcc4a2012-04-10 01:32:12 +0000117 void const_after_attr () [[]] const; // expected-error {{expected ';'}}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000118};
119extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
120[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
Richard Smithf4c51d92012-02-04 09:53:13 +0000121[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000122[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
123[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
124
125[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
Richard Smith54ecd982013-02-20 19:22:51 +0000126[[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000127[[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
Aaron Ballmanc0ae7df2014-11-08 17:07:15 +0000128namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are incompatible with C++ standards before C++1z}}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000129
Richard Smithc2c8bb82013-10-15 01:34:54 +0000130using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
131using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
132
133void bad_attributes_in_do_while() {
134 do {} while (
135 [[ns::i); // expected-error {{expected ']'}} \
136 // expected-note {{to match this '['}} \
137 // expected-error {{expected expression}}
138 do {} while (
139 [[a]b ns::i); // expected-error {{expected ']'}} \
140 // expected-note {{to match this '['}} \
141 // expected-error {{expected expression}}
142 do {} while (
143 [[ab]ab] ns::i); // expected-error {{an attribute list cannot appear here}}
144 do {} while ( // expected-note {{to match this '('}}
145 alignas(4 ns::i; // expected-note {{to match this '('}}
146} // expected-error 2{{expected ')'}} expected-error {{expected expression}}
147
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000148[[]] using T = int; // expected-error {{an attribute list cannot appear here}}
149using T [[]] = int; // ok
150template<typename T> using U [[]] = T;
151using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
152using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
Richard Smith54ecd982013-02-20 19:22:51 +0000153using T [[unknown]] = int; // expected-warning {{unknown attribute 'unknown' ignored}}
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000154using T [[noreturn]] = int; // expected-error {{'noreturn' attribute only applies to functions}}
Richard Smith54ecd982013-02-20 19:22:51 +0000155using V = int; // expected-note {{previous}}
156using V [[gnu::vector_size(16)]] = int; // expected-error {{redefinition with different types}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000157
158auto trailing() -> [[]] const int; // expected-error {{an attribute list cannot appear here}}
159auto trailing() -> const [[]] int; // expected-error {{an attribute list cannot appear here}}
160auto trailing() -> const int [[]];
161auto trailing_2() -> struct struct_attr [[]];
162
163namespace N {
164 struct S {};
165};
166template<typename> struct Template {};
167
168// FIXME: Improve this diagnostic
169struct [[]] N::S s; // expected-error {{an attribute list cannot appear here}}
170struct [[]] Template<int> t; // expected-error {{an attribute list cannot appear here}}
171struct [[]] ::template Template<int> u; // expected-error {{an attribute list cannot appear here}}
172template struct [[]] Template<char>; // expected-error {{an attribute list cannot appear here}}
173template <> struct [[]] Template<void>;
174
175enum [[]] E1 {};
176enum [[]] E2; // expected-error {{forbids forward references}}
177enum [[]] E1;
178enum [[]] E3 : int;
179enum [[]] {
Aaron Ballmanc0ae7df2014-11-08 17:07:15 +0000180 k_123 [[]] = 123 // expected-warning {{attributes on an enumerator declaration are incompatible with C++ standards before C++1z}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000181};
182enum [[]] E1 e; // expected-error {{an attribute list cannot appear here}}
183enum [[]] class E4 { }; // expected-error {{an attribute list cannot appear here}}
184enum struct [[]] E5;
185
186struct S {
187 friend int f [[]] (); // expected-FIXME{{an attribute list cannot appear here}}
Michael Handdc016d2012-11-28 23:17:40 +0000188 friend int f1 [[noreturn]] (); //expected-error{{an attribute list cannot appear here}}
189 friend int f2 [[]] [[noreturn]] () {}
190 [[]] friend int g(); // expected-error{{an attribute list cannot appear here}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000191 [[]] friend int h() {
192 }
Michael Handdc016d2012-11-28 23:17:40 +0000193 [[]] friend int f3(), f4(), f5(); // expected-error{{an attribute list cannot appear here}}
194 friend int f6 [[noreturn]] (), f7 [[noreturn]] (), f8 [[noreturn]] (); // expected-error3 {{an attribute list cannot appear here}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000195 friend class [[]] C; // expected-error{{an attribute list cannot appear here}}
Michael Handdc016d2012-11-28 23:17:40 +0000196 [[]] friend class D; // expected-error{{an attribute list cannot appear here}}
197 [[]] friend int; // expected-error{{an attribute list cannot appear here}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000198};
199template<typename T> void tmpl(T) {}
200template void tmpl [[]] (int); // expected-FIXME {{an attribute list cannot appear here}}
201template [[]] void tmpl(char); // expected-error {{an attribute list cannot appear here}}
202template void [[]] tmpl(short);
203
Alexis Hunt96d5c762009-11-21 08:43:09 +0000204// Argument tests
Peter Collingbourne2f3cf4b2011-09-29 18:04:28 +0000205alignas int aligned_no_params; // expected-error {{expected '('}}
Richard Smithf4c51d92012-02-04 09:53:13 +0000206alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
Alexis Hunt96d5c762009-11-21 08:43:09 +0000207
208// Statement tests
209void foo () {
210 [[]] ;
211 [[]] { }
212 [[]] if (0) { }
213 [[]] for (;;);
214 [[]] do {
215 [[]] continue;
216 } while (0);
217 [[]] while (0);
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000218
Alexis Hunt96d5c762009-11-21 08:43:09 +0000219 [[]] switch (i) {
220 [[]] case 0:
221 [[]] default:
222 [[]] break;
223 }
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000224
Alexis Hunt96d5c762009-11-21 08:43:09 +0000225 [[]] goto there;
226 [[]] there:
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000227
Alexis Hunt96d5c762009-11-21 08:43:09 +0000228 [[]] try {
229 } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
230 }
Richard Smith7bdcc4a2012-04-10 01:32:12 +0000231 struct S { int arr[2]; } s;
232 (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
233 int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
234
Richard Smith2620cd92012-04-11 04:01:28 +0000235 void bar [[noreturn]] ([[]] int i, [[]] int j);
236 using FuncType = void ([[]] int);
237 void baz([[]]...); // expected-error {{expected parameter declarator}}
238
Alexis Hunt96d5c762009-11-21 08:43:09 +0000239 [[]] return;
240}
Richard Smith3dff2512012-04-10 03:25:07 +0000241
242template<typename...Ts> void variadic() {
243 void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
244}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000245
246// Expression tests
247void bar () {
Richard Smith10876ef2013-01-17 01:30:42 +0000248 // FIXME: GCC accepts [[gnu::noreturn]] on a lambda, even though it appertains
249 // to the operator()'s type, and GCC does not otherwise accept attributes
250 // applied to types. Use that to test this.
251 [] () [[gnu::noreturn]] { return; } (); // expected-warning {{attribute 'noreturn' ignored}} FIXME-error {{should not return}}
252 [] () [[gnu::noreturn]] { throw; } (); // expected-warning {{attribute 'noreturn' ignored}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000253 new int[42][[]][5][[]]{};
254}
255
256// Condition tests
257void baz () {
Richard Smith54ecd982013-02-20 19:22:51 +0000258 if ([[unknown]] bool b = true) { // expected-warning {{unknown attribute 'unknown' ignored}}
259 switch ([[unknown]] int n { 42 }) { // expected-warning {{unknown attribute 'unknown' ignored}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000260 default:
Richard Smith54ecd982013-02-20 19:22:51 +0000261 for ([[unknown]] int n = 0; [[unknown]] char b = n < 5; ++b) { // expected-warning 2{{unknown attribute 'unknown' ignored}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000262 }
263 }
264 }
265 int x;
266 // An attribute can be applied to an expression-statement, such as the first
267 // statement in a for. But it can't be applied to a condition which is an
268 // expression.
269 for ([[]] x = 0; ; ) {} // expected-error {{an attribute list cannot appear here}}
270 for (; [[]] x < 5; ) {} // expected-error {{an attribute list cannot appear here}}
271 while ([[]] bool k { false }) {
272 }
273 while ([[]] true) { // expected-error {{an attribute list cannot appear here}}
274 }
275 do {
276 } while ([[]] false); // expected-error {{an attribute list cannot appear here}}
277
Richard Smith54ecd982013-02-20 19:22:51 +0000278 for ([[unknown]] int n : { 1, 2, 3 }) { // expected-warning {{unknown attribute 'unknown' ignored}}
Alexis Hunt6aa9bee2012-06-23 05:07:58 +0000279 }
280}
John McCallbeae29a2012-06-23 22:30:04 +0000281
282enum class __attribute__((visibility("hidden"))) SecretKeepers {
283 one, /* rest are deprecated */ two, three
284};
285enum class [[]] EvenMoreSecrets {};
Michael Han23214e52012-10-03 01:56:22 +0000286
287namespace arguments {
Richard Smith368ca522013-01-14 07:53:01 +0000288 void f[[gnu::format(printf, 1, 2)]](const char*, ...);
Aaron Ballmanb8e20392014-03-31 17:32:39 +0000289 void g() [[unknown::foo(ignore arguments for unknown attributes, even with symbols!)]]; // expected-warning {{unknown attribute 'foo' ignored}}
290 [[deprecated("with argument")]] int i;
Aaron Ballmanf25731a2015-02-16 23:12:37 +0000291 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
Michael Han23214e52012-10-03 01:56:22 +0000292}
Michael Han64536a62012-11-06 19:34:54 +0000293
Richard Smith368ca522013-01-14 07:53:01 +0000294// Forbid attributes on decl specifiers.
Richard Smith810ad3e2013-01-29 10:02:16 +0000295unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-error {{'unused' attribute cannot be applied to types}} \
Michael Han64536a62012-11-06 19:34:54 +0000296 expected-error {{an attribute list cannot appear here}}
Richard Smith810ad3e2013-01-29 10:02:16 +0000297typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-error {{'unused' attribute cannot be applied to types}} \
Michael Han64536a62012-11-06 19:34:54 +0000298 expected-error {{an attribute list cannot appear here}}
Richard Smith810ad3e2013-01-29 10:02:16 +0000299int [[carries_dependency]] foo(int [[carries_dependency]] x); // expected-error 2{{'carries_dependency' attribute cannot be applied to types}}
Richard Smith368ca522013-01-14 07:53:01 +0000300
301// Forbid [[gnu::...]] attributes on declarator chunks.
302int *[[gnu::unused]] v3; // expected-warning {{attribute 'unused' ignored}}
303int v4[2][[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
304int v5()[[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
Richard Smith54ecd982013-02-20 19:22:51 +0000305
306[[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}}
Aaron Ballman3a8e2d92013-11-27 18:53:58 +0000307[[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}}
Michael Han84324352013-02-22 17:15:32 +0000308[[carries_dependency]]; // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
Richard Smithf2163662013-09-06 00:12:20 +0000309
310class A {
311 A([[gnu::unused]] int a);
312};
313A::A([[gnu::unused]] int a) {}
Nick Lewyckyd0604672013-10-29 03:33:57 +0000314
315namespace GccConst {
316 // GCC's tokenizer treats const and __const as the same token.
317 [[gnu::const]] int *f1();
318 [[gnu::__const]] int *f2();
Saleem Abdulrasool73196ba2013-11-30 21:17:12 +0000319 [[gnu::__const__]] int *f3();
Nick Lewyckyd0604672013-10-29 03:33:57 +0000320 void f(const int *);
321 void g() { f(f1()); f(f2()); }
Saleem Abdulrasool73196ba2013-11-30 21:17:12 +0000322 void h() { f(f3()); }
Nick Lewyckyd0604672013-10-29 03:33:57 +0000323}
Nick Lewycky2c531162013-10-29 03:54:41 +0000324
325namespace GccASan {
326 __attribute__((no_address_safety_analysis)) void f1();
327 __attribute__((no_sanitize_address)) void f2();
328 [[gnu::no_address_safety_analysis]] void f3();
329 [[gnu::no_sanitize_address]] void f4();
330}
Aaron Ballman35f94212014-04-14 16:03:22 +0000331
332namespace {
333 [[deprecated]] void bar();
Aaron Ballmanf25731a2015-02-16 23:12:37 +0000334 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
Aaron Ballman35f94212014-04-14 16:03:22 +0000335 [[deprecated("hello")]] void baz();
Aaron Ballmanf25731a2015-02-16 23:12:37 +0000336 // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 extension}}
Saleem Abdulrasoolf931a382015-02-16 22:27:01 +0000337 [[deprecated()]] void foo();
338 // expected-error@-1 {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
Aaron Ballman35f94212014-04-14 16:03:22 +0000339 [[gnu::deprecated()]] void quux();
340}
David Majnemerd5271992015-01-09 18:09:39 +0000341
342namespace {
343[[ // expected-error {{expected ']'}}
344#pragma pack(pop)
345deprecated
346]] void bad();
347}
Benjamin Kramer60be5632015-03-29 19:25:07 +0000348
Richard Smith4f902c72016-03-08 00:32:55 +0000349int fallthru(int n) {
350 switch (n) {
351 case 0:
352 n += 5;
353 [[fallthrough]]; // expected-warning {{use of the 'fallthrough' attribute is a C++1z extension}}
354 case 1:
355 n *= 2;
356 break;
357 }
358 return n;
359}
360
Benjamin Kramer60be5632015-03-29 19:25:07 +0000361#define attr_name bitand
362#define attr_name_2(x) x
363#define attr_name_3(x, y) x##y
364[[attr_name, attr_name_2(bitor), attr_name_3(com, pl)]] int macro_attrs; // expected-warning {{unknown attribute 'compl' ignored}} \
365 expected-warning {{unknown attribute 'bitor' ignored}} \
366 expected-warning {{unknown attribute 'bitand' ignored}}