1 // RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions -triple aarch64-none-linux-gnu -target-feature +sme %s
3 // Need std::initializer_list
5 typedef decltype(sizeof(int)) size_t;
7 // libc++'s implementation
14 initializer_list(const _E
* __b
, size_t __s
)
20 typedef _E value_type
;
21 typedef const _E
& reference
;
22 typedef const _E
& const_reference
;
23 typedef size_t size_type
;
25 typedef const _E
* iterator
;
26 typedef const _E
* const_iterator
;
28 initializer_list() : __begin_(nullptr), __size_(0) {}
30 size_t size() const {return __size_
;}
31 const _E
* begin() const {return __begin_
;}
32 const _E
* end() const {return __begin_
+ __size_
;}
37 // Declaration syntax checks
38 __arm_streaming
int before_attr
; // expected-error {{'__arm_streaming' only applies to function types}}
39 int __arm_streaming between_attr
; // expected-error {{'__arm_streaming' only applies to function types}}
40 const __arm_streaming
int between_attr_2
= 0; // expected-error {{'__arm_streaming' cannot appear here}}
41 int after_attr __arm_streaming
; // expected-error {{'__arm_streaming' only applies to function types}}
42 int * __arm_streaming ptr_attr
; // expected-error {{'__arm_streaming' only applies to function types}}
43 int & __arm_streaming ref_attr
= after_attr
; // expected-error {{'__arm_streaming' only applies to function types}}
44 int && __arm_streaming rref_attr
= 0; // expected-error {{'__arm_streaming' only applies to function types}}
45 int array_attr
[1] __arm_streaming
; // expected-error {{'__arm_streaming' only applies to function types}}
46 void fn_attr () __arm_streaming
;
47 void noexcept_fn_attr () noexcept __arm_streaming
;
48 struct MemberFnOrder
{
49 virtual void f() const volatile && noexcept __arm_streaming final
= 0;
51 struct __arm_streaming struct_attr
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
52 class __arm_streaming class_attr
{}; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
53 union __arm_streaming union_attr
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
54 enum __arm_streaming E
{ }; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
55 namespace test_misplacement
{
56 __arm_streaming
struct struct_attr2
; // expected-error {{misplaced '__arm_streaming'}}
57 __arm_streaming
class class_attr2
; // expected-error {{misplaced '__arm_streaming'}}
58 __arm_streaming
union union_attr2
; // expected-error {{misplaced '__arm_streaming'}}
59 __arm_streaming
enum E2
{ }; // expected-error {{misplaced '__arm_streaming'}}
62 // Checks attributes placed at wrong syntactic locations of class specifiers.
63 class __arm_streaming __arm_streaming
// expected-error 2 {{'__arm_streaming' only applies to non-K&R-style functions}}
64 attr_after_class_name_decl __arm_streaming __arm_streaming
; // expected-error {{'__arm_streaming' cannot appear here}} \
65 expected
-error
2 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
67 class __arm_streaming __arm_streaming
// expected-error 2 {{'__arm_streaming' only applies to non-K&R-style functions}}
68 attr_after_class_name_definition __arm_streaming __arm_streaming __arm_streaming
{}; // expected-error {{'__arm_streaming' cannot appear here}} \
69 expected
-error
3 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
71 class __arm_streaming c
{}; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
72 class c __arm_streaming __arm_streaming x
; // expected-error 2 {{'__arm_streaming' only applies to function types}}
73 class c __arm_streaming __arm_streaming y __arm_streaming __arm_streaming
; // expected-error 4 {{'__arm_streaming' only applies to function types}}
74 class c final
[(int){0}];
77 class __arm_streaming __arm_streaming final_class
// expected-error 2 {{'__arm_streaming' only applies to non-K&R-style functions}}
78 __arm_streaming
alignas(float) final
// expected-error {{'__arm_streaming' cannot appear here}} \
79 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
80 __arm_streaming
alignas(float) __arm_streaming
alignas(float): base
{}; // expected-error {{'__arm_streaming' cannot appear here}}
82 class __arm_streaming __arm_streaming final_class_another
// expected-error 2 {{'__arm_streaming' only applies to non-K&R-style functions}}
83 __arm_streaming __arm_streaming
alignas(16) final
// expected-error {{'__arm_streaming' cannot appear here}} \
84 expected
-error
2 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
85 __arm_streaming __arm_streaming
alignas(16) __arm_streaming
{}; // expected-error {{'__arm_streaming' cannot appear here}}
87 class after_class_close
{} __arm_streaming
; // expected-error {{'__arm_streaming' cannot appear here, place it after "class" to apply it to the type declaration}}
91 __arm_streaming
struct with_init_declarators
{} init_declarator
; // expected-error {{'__arm_streaming' only applies to function types}}
92 __arm_streaming
struct no_init_declarators
; // expected-error {{misplaced '__arm_streaming'}}
93 template<typename
> __arm_streaming
struct no_init_declarators_template
; // expected-error {{'__arm_streaming' cannot appear here}}
94 void fn_with_structs() {
95 __arm_streaming
struct with_init_declarators
{} init_declarator
; // expected-error {{'__arm_streaming' only applies to function types}}
96 __arm_streaming
struct no_init_declarators
; // expected-error {{'__arm_streaming' cannot appear here}}
98 __arm_streaming
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
100 __arm_streaming ctordtor
__arm_streaming () __arm_streaming
; // expected-error 2 {{'__arm_streaming' cannot be applied to a declaration}}
101 ctordtor (C
) __arm_streaming
;
102 __arm_streaming
~ctordtor
__arm_streaming () __arm_streaming
; // expected-error 2 {{'__arm_streaming' cannot be applied to a declaration}}
104 __arm_streaming
ctordtor::ctordtor
__arm_streaming () __arm_streaming
{} // expected-error 2 {{'__arm_streaming' cannot be applied to a declaration}}
105 __arm_streaming
ctordtor::ctordtor (C
) __arm_streaming
try {} catch (...) {} // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
106 __arm_streaming
ctordtor::~ctordtor
__arm_streaming () __arm_streaming
{} // expected-error 2 {{'__arm_streaming' cannot be applied to a declaration}}
107 extern "C++" __arm_streaming
int extern_attr
; // expected-error {{'__arm_streaming' only applies to function types}}
108 template <typename T
> __arm_streaming
void template_attr (); // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
109 __arm_streaming __arm_streaming
int __arm_streaming __arm_streaming multi_attr __arm_streaming __arm_streaming
; // expected-error 6 {{'__arm_streaming' only applies to function types}}
111 int (paren_attr
) __arm_streaming
; // expected-error {{'__arm_streaming' cannot appear here}}
112 unsigned __arm_streaming
int attr_in_decl_spec
; // expected-error {{'__arm_streaming' cannot appear here}}
113 unsigned __arm_streaming
int __arm_streaming
const double_decl_spec
= 0; // expected-error 2 {{'__arm_streaming' cannot appear here}}
115 void const_after_attr () __arm_streaming
const; // expected-error {{expected ';'}}
117 extern "C++" __arm_streaming
{ } // expected-error {{'__arm_streaming' cannot appear here}}
118 __arm_streaming
extern "C++" { } // expected-error {{'__arm_streaming' cannot appear here}}
119 __arm_streaming
template <typename T
> void before_template_attr (); // expected-error {{'__arm_streaming' cannot appear here}}
120 __arm_streaming
namespace ns
{ int i
; } // expected-error {{'__arm_streaming' cannot appear here}}
121 __arm_streaming
static_assert(true, ""); //expected-error {{'__arm_streaming' cannot appear here}}
122 __arm_streaming
asm(""); // expected-error {{'__arm_streaming' cannot appear here}}
124 __arm_streaming
using ns::i
; // expected-warning {{ISO C++}} \
125 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
126 __arm_streaming
using namespace ns
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
127 namespace __arm_streaming ns2
{} // expected-warning {{attributes on a namespace declaration are a C++17 extension}} \
128 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
130 using __arm_streaming
alignas(4)__arm_streaming
ns::i
; // expected-warning 2 {{ISO C++}} \
131 expected
-error
{{'__arm_streaming' cannot appear here
}} \
132 expected
-error
{{'alignas' attribute only applies to variables
, data members
and tag types
}} \
133 expected
-warning
{{ISO C
++}} \
134 expected
-error
2 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
135 using __arm_streaming
alignas(4) __arm_streaming foobar
= int; // expected-error {{'__arm_streaming' cannot appear here}} \
136 expected
-error
{{'alignas' attribute only applies to
}} \
137 expected
-error
2 {{'__arm_streaming' only applies to function types
}}
139 __arm_streaming
using T
= int; // expected-error {{'__arm_streaming' cannot appear here}}
140 using T __arm_streaming
= int; // expected-error {{'__arm_streaming' only applies to function types}}
141 template<typename T
> using U __arm_streaming
= T
; // expected-error {{'__arm_streaming' only applies to function types}}
142 using ns::i __arm_streaming
; // expected-warning {{ISO C++}} \
143 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
144 using ns::i __arm_streaming
, ns::i __arm_streaming
; // expected-warning 2 {{ISO C++}} \
145 expected
-warning
{{use of multiple declarators in a single
using declaration is a C
++17 extension
}} \
146 expected
-error
2 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
147 struct using_in_struct_base
{
148 typedef int i
, j
, k
, l
;
150 struct using_in_struct
: using_in_struct_base
{
151 __arm_streaming
using using_in_struct_base::i
; // expected-warning {{ISO C++}} \
152 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
153 using using_in_struct_base::j __arm_streaming
; // expected-warning {{ISO C++}} \
154 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
155 __arm_streaming
using using_in_struct_base::k __arm_streaming
, using_in_struct_base::l __arm_streaming
; // expected-warning 3 {{ISO C++}} \
156 expected
-warning
{{use of multiple declarators in a single
using declaration is a C
++17 extension
}} \
157 expected
-error
4 {{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
159 using __arm_streaming
ns::i
; // expected-warning {{ISO C++}} \
160 expected
-error
{{'__arm_streaming' cannot appear here
}} \
161 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
162 using T __arm_streaming
= int; // expected-error {{'__arm_streaming' only applies to function types}}
164 auto trailing() -> __arm_streaming
const int; // expected-error {{'__arm_streaming' cannot appear here}}
165 auto trailing() -> const __arm_streaming
int; // expected-error {{'__arm_streaming' cannot appear here}}
166 auto trailing() -> const int __arm_streaming
; // expected-error {{'__arm_streaming' only applies to function types}}
167 auto trailing_2() -> struct struct_attr __arm_streaming
; // expected-error {{'__arm_streaming' only applies to function types}}
172 template<typename
> struct Template
{};
174 // FIXME: Improve this diagnostic
175 struct __arm_streaming
N::S s
; // expected-error {{'__arm_streaming' cannot appear here}}
176 struct __arm_streaming Template
<int> t
; // expected-error {{'__arm_streaming' cannot appear here}}
177 struct __arm_streaming ::template Template
<int> u
; // expected-error {{'__arm_streaming' cannot appear here}}
178 template struct __arm_streaming Template
<char>; // expected-error {{'__arm_streaming' cannot appear here}}
179 template struct __attribute__((pure
)) Template
<std::size_t>; // We still allow GNU-style attributes here
180 template <> struct __arm_streaming Template
<void>; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
182 enum __arm_streaming E1
{}; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
183 enum __arm_streaming E2
; // expected-error {{forbids forward references}} \
184 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
185 enum __arm_streaming E1
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
186 enum __arm_streaming E3
: int; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
187 enum __arm_streaming
{ // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
188 k_123 __arm_streaming
= 123 // expected-warning {{attributes on an enumerator declaration are a C++17 extension}} \
189 expected
-error
{{'__arm_streaming' only applies to non
-K
&R
-style functions
}}
191 enum __arm_streaming E1 e
; // expected-error {{'__arm_streaming' cannot appear here}}
192 enum __arm_streaming
class E4
{ }; // expected-error {{'__arm_streaming' cannot appear here}}
193 enum struct __arm_streaming E5
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
194 enum E6
{} __arm_streaming
; // expected-error {{'__arm_streaming' cannot appear here, place it after "enum" to apply it to the type declaration}}
197 friend int f
__arm_streaming (); // expected-error {{'__arm_streaming' cannot appear here}} \
198 expected
-error
{{'__arm_streaming' cannot be applied to a declaration
}}
199 friend int f2
__arm_streaming () {} // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
200 __arm_streaming
friend int g(); // expected-error {{'__arm_streaming' cannot appear here}}
201 __arm_streaming
friend int h() { // expected-error {{'__arm_streaming' cannot be applied to a declaration}}
203 __arm_streaming
friend int f3(), f4(), f5(); // expected-error {{'__arm_streaming' cannot appear here}}
204 friend int f6
__arm_streaming (), f7
__arm_streaming (), f8
__arm_streaming (); // expected-error3 {{'__arm_streaming' cannot appear here}} \
205 expected
-error
3 {{'__arm_streaming' cannot be applied to a declaration
}}
206 friend class __arm_streaming C
; // expected-error {{'__arm_streaming' cannot appear here}}
207 __arm_streaming
friend class D
; // expected-error {{'__arm_streaming' cannot appear here}}
208 __arm_streaming
friend int; // expected-error {{'__arm_streaming' cannot appear here}}
210 template<typename T
> void tmpl (T
) {}
211 template __arm_streaming
void tmpl(char); // expected-error {{'__arm_streaming' cannot appear here}}
212 template void __arm_streaming
tmpl(short); // expected-error {{'__arm_streaming' only applies to function types}}
216 __arm_streaming
; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
217 __arm_streaming
{ } // expected-error {{'__arm_streaming' cannot be applied to a statement}}
218 __arm_streaming
if (0) { } // expected-error {{'__arm_streaming' cannot be applied to a statement}}
219 __arm_streaming
for (;;); // expected-error {{'__arm_streaming' cannot be applied to a statement}}
220 __arm_streaming
do { // expected-error {{'__arm_streaming' cannot be applied to a statement}}
221 __arm_streaming
continue; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
223 __arm_streaming
while (0); // expected-error {{'__arm_streaming' cannot be applied to a statement}}
225 __arm_streaming
switch (i
) { // expected-error {{'__arm_streaming' cannot be applied to a statement}}
226 __arm_streaming
case 0: // expected-error {{'__arm_streaming' cannot be applied to a statement}}
227 __arm_streaming
default: // expected-error {{'__arm_streaming' cannot be applied to a statement}}
228 __arm_streaming
break; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
231 __arm_streaming
goto there
; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
232 __arm_streaming there
: // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
234 __arm_streaming
try { // expected-error {{'__arm_streaming' cannot be applied to a statement}}
235 } __arm_streaming
catch (...) { // expected-error {{'__arm_streaming' cannot appear here}}
238 void bar
__arm_streaming (__arm_streaming
int i
, __arm_streaming
int j
); // expected-error 2 {{'__arm_streaming' only applies to function types}} \
239 expected
-error
{{'__arm_streaming' cannot be applied to a declaration
}}
240 using FuncType
= void (__arm_streaming
int); // expected-error {{'__arm_streaming' only applies to function types}}
241 void baz(__arm_streaming
...); // expected-error {{expected parameter declarator}}
243 __arm_streaming
return; // expected-error {{'__arm_streaming' cannot be applied to a statement}}
248 new int[42]__arm_streaming
[5]__arm_streaming
{}; // expected-error {{'__arm_streaming' only applies to function types}}
253 if (__arm_streaming
bool b
= true) { // expected-error {{'__arm_streaming' only applies to function types}}
254 switch (__arm_streaming
int n
{ 42 }) { // expected-error {{'__arm_streaming' only applies to function types}}
256 for (__arm_streaming
int n
= 0; __arm_streaming
char b
= n
< 5; ++b
) { // expected-error 2 {{'__arm_streaming' only applies to function types}}
261 // An attribute can be applied to an expression-statement, such as the first
262 // statement in a for. But it can't be applied to a condition which is an
264 for (__arm_streaming x
= 0; ; ) {} // expected-error {{'__arm_streaming' cannot appear here}}
265 for (; __arm_streaming x
< 5; ) {} // expected-error {{'__arm_streaming' cannot appear here}}
266 while (__arm_streaming
bool k
{ false }) { // expected-error {{'__arm_streaming' only applies to function types}}
268 while (__arm_streaming
true) { // expected-error {{'__arm_streaming' cannot appear here}}
271 } while (__arm_streaming
false); // expected-error {{'__arm_streaming' cannot appear here}}
273 for (__arm_streaming
int n
: { 1, 2, 3 }) { // expected-error {{'__arm_streaming' only applies to function types}}
277 enum class __attribute__((visibility("hidden"))) SecretKeepers
{
278 one
, /* rest are deprecated */ two
, three
280 enum class __arm_streaming EvenMoreSecrets
{}; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
282 // Forbid attributes on decl specifiers.
283 unsigned __arm_streaming
static int __arm_streaming v1
; // expected-error {{'__arm_streaming' only applies to function types}} \
284 expected
-error
{{'__arm_streaming' cannot appear here
}}
285 typedef __arm_streaming
unsigned long __arm_streaming v2
; // expected-error {{'__arm_streaming' only applies to function types}} \
286 expected
-error
{{'__arm_streaming' cannot appear here
}}
287 int __arm_streaming
foo(int __arm_streaming x
); // expected-error 2 {{'__arm_streaming' only applies to function types}}
289 __arm_streaming
; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}}
292 A(__arm_streaming
int a
); // expected-error {{'__arm_streaming' only applies to function types}}
294 A::A(__arm_streaming
int a
) {} // expected-error {{'__arm_streaming' only applies to function types}}
296 template<typename T
> struct TemplateStruct
{};
297 class FriendClassesWithAttributes
{
298 // We allow GNU-style attributes here
299 template <class _Tp
, class _Alloc
> friend class __attribute__((__type_visibility__("default"))) vector
;
300 template <class _Tp
, class _Alloc
> friend class __declspec(code_seg("foo,whatever")) vector2
;
301 // But not C++11 ones
302 template <class _Tp
, class _Alloc
> friend class __arm_streaming vector3
; // expected-error {{'__arm_streaming' cannot appear here}}
305 friend struct __attribute__((__type_visibility__("default"))) TemplateStruct
<FriendClassesWithAttributes
>;
306 friend struct __declspec(code_seg("foo,whatever")) TemplateStruct
<FriendClassesWithAttributes
>;
307 friend struct __arm_streaming TemplateStruct
<FriendClassesWithAttributes
>; // expected-error {{'__arm_streaming' cannot appear here}}
310 // Check ordering: C++11 attributes must appear before GNU attributes.
313 int (__arm_streaming
__attribute__(()) int n
) // expected-error {{'__arm_streaming' only applies to function types}}
318 int (*)(__arm_streaming
__attribute__(()) int n
) // expected-error {{'__arm_streaming' only applies to function types}}
323 int (__attribute__(()) __arm_streaming
int n
) // expected-error {{'__arm_streaming' cannot appear here}}
328 int (*)(__attribute__(()) __arm_streaming
int n
) // expected-error {{'__arm_streaming' cannot appear here}}
333 namespace base_specs
{
335 struct B
: __arm_streaming A
{}; // expected-error {{'__arm_streaming' cannot be applied to a base specifier}}
336 struct C
: __arm_streaming
virtual A
{}; // expected-error {{'__arm_streaming' cannot be applied to a base specifier}}
337 struct D
: __arm_streaming
public virtual A
{}; // expected-error {{'__arm_streaming' cannot be applied to a base specifier}}
338 struct E
: public __arm_streaming
virtual A
{}; // expected-error {{'__arm_streaming' cannot appear here}} \
339 expected
-error
{{'__arm_streaming' cannot be applied to a base specifier
}}
340 struct F
: virtual __arm_streaming
public A
{}; // expected-error {{'__arm_streaming' cannot appear here}} \
341 expected
-error
{{'__arm_streaming' cannot be applied to a base specifier
}}
344 namespace __arm_streaming ns_attr
{}; // expected-error {{'__arm_streaming' only applies to non-K&R-style functions}} \
345 expected
-warning
{{attributes on a
namespace declaration are a C
++17 extension
}}