1 // RUN: sed -e "s@ATTR_USE@__arm_streaming@g" -e "s@ATTR_NAME@__arm_streaming@g" %s > %t
2 // 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 -x c++ %t
3 // RUN: sed -e "s@ATTR_USE@__arm_inout\(\"za\"\)@g" -e "s@ATTR_NAME@__arm_inout@g" %s > %t
4 // 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 -x c++ %t
6 // Need std::initializer_list
8 typedef decltype(sizeof(int)) size_t;
10 // libc++'s implementation
12 class initializer_list
17 initializer_list(const _E
* __b
, size_t __s
)
23 typedef _E value_type
;
24 typedef const _E
& reference
;
25 typedef const _E
& const_reference
;
26 typedef size_t size_type
;
28 typedef const _E
* iterator
;
29 typedef const _E
* const_iterator
;
31 initializer_list() : __begin_(nullptr), __size_(0) {}
33 size_t size() const {return __size_
;}
34 const _E
* begin() const {return __begin_
;}
35 const _E
* end() const {return __begin_
+ __size_
;}
40 // Declaration syntax checks
41 ATTR_USE
int before_attr
; // expected-error {{'ATTR_NAME' only applies to function types}}
42 int ATTR_USE between_attr
; // expected-error {{'ATTR_NAME' only applies to function types}}
43 const ATTR_USE
int between_attr_2
= 0; // expected-error {{'ATTR_NAME' cannot appear here}}
44 int after_attr ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to function types}}
45 int * ATTR_USE ptr_attr
; // expected-error {{'ATTR_NAME' only applies to function types}}
46 int & ATTR_USE ref_attr
= after_attr
; // expected-error {{'ATTR_NAME' only applies to function types}}
47 int && ATTR_USE rref_attr
= 0; // expected-error {{'ATTR_NAME' only applies to function types}}
48 int array_attr
[1] ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to function types}}
49 void fn_attr () ATTR_USE
;
50 void noexcept_fn_attr () noexcept ATTR_USE
;
51 struct MemberFnOrder
{
52 virtual void f() const volatile && noexcept ATTR_USE final
= 0;
54 struct ATTR_USE struct_attr
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
55 class ATTR_USE class_attr
{}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
56 union ATTR_USE union_attr
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
57 enum ATTR_USE E
{ }; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
58 namespace test_misplacement
{
59 ATTR_USE
struct struct_attr2
; // expected-error {{misplaced 'ATTR_NAME'}}
60 ATTR_USE
class class_attr2
; // expected-error {{misplaced 'ATTR_NAME'}}
61 ATTR_USE
union union_attr2
; // expected-error {{misplaced 'ATTR_NAME'}}
62 ATTR_USE
enum E2
{ }; // expected-error {{misplaced 'ATTR_NAME'}}
65 // Checks attributes placed at wrong syntactic locations of class specifiers.
66 class ATTR_USE ATTR_USE
// expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
67 attr_after_class_name_decl ATTR_USE ATTR_USE
; // expected-error {{'ATTR_NAME' cannot appear here}} \
68 expected
-error
2 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
70 class ATTR_USE ATTR_USE
// expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
71 attr_after_class_name_definition ATTR_USE ATTR_USE ATTR_USE
{}; // expected-error {{'ATTR_NAME' cannot appear here}} \
72 expected
-error
3 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
74 class ATTR_USE c
{}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
75 class c ATTR_USE ATTR_USE x
; // expected-error 2 {{'ATTR_NAME' only applies to function types}}
76 class c ATTR_USE ATTR_USE y ATTR_USE ATTR_USE
; // expected-error 4 {{'ATTR_NAME' only applies to function types}}
77 class c final
[(int){0}];
80 class ATTR_USE ATTR_USE final_class
// expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
81 ATTR_USE
alignas(float) final
// expected-error {{'ATTR_NAME' cannot appear here}} \
82 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
83 ATTR_USE
alignas(float) ATTR_USE
alignas(float): base
{}; // expected-error {{'ATTR_NAME' cannot appear here}}
85 class ATTR_USE ATTR_USE final_class_another
// expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
86 ATTR_USE ATTR_USE
alignas(16) final
// expected-error {{'ATTR_NAME' cannot appear here}} \
87 expected
-error
2 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
88 ATTR_USE ATTR_USE
alignas(16) ATTR_USE
{}; // expected-error {{'ATTR_NAME' cannot appear here}}
90 class after_class_close
{} ATTR_USE
; // expected-error {{'ATTR_NAME' cannot appear here, place it after "class" to apply it to the type declaration}}
94 ATTR_USE
struct with_init_declarators
{} init_declarator
; // expected-error {{'ATTR_NAME' only applies to function types}}
95 ATTR_USE
struct no_init_declarators
; // expected-error {{misplaced 'ATTR_NAME'}}
96 template<typename
> ATTR_USE
struct no_init_declarators_template
; // expected-error {{'ATTR_NAME' cannot appear here}}
97 void fn_with_structs() {
98 ATTR_USE
struct with_init_declarators
{} init_declarator
; // expected-error {{'ATTR_NAME' only applies to function types}}
99 ATTR_USE
struct no_init_declarators
; // expected-error {{'ATTR_NAME' cannot appear here}}
101 ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
103 ATTR_USE ctordtor
ATTR_USE () ATTR_USE
; // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
104 ctordtor (C
) ATTR_USE
;
105 ATTR_USE
~ctordtor
ATTR_USE () ATTR_USE
; // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
107 ATTR_USE
ctordtor::ctordtor
ATTR_USE () ATTR_USE
{} // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
108 ATTR_USE
ctordtor::ctordtor (C
) ATTR_USE
try {} catch (...) {} // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
109 ATTR_USE
ctordtor::~ctordtor
ATTR_USE () ATTR_USE
{} // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
110 extern "C++" ATTR_USE
int extern_attr
; // expected-error {{'ATTR_NAME' only applies to function types}}
111 template <typename T
> ATTR_USE
void template_attr (); // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
112 ATTR_USE ATTR_USE
int ATTR_USE ATTR_USE multi_attr ATTR_USE ATTR_USE
; // expected-error 6 {{'ATTR_NAME' only applies to function types}}
114 int (paren_attr
) ATTR_USE
; // expected-error {{'ATTR_NAME' cannot appear here}}
115 unsigned ATTR_USE
int attr_in_decl_spec
; // expected-error {{'ATTR_NAME' cannot appear here}}
116 unsigned ATTR_USE
int ATTR_USE
const double_decl_spec
= 0; // expected-error 2 {{'ATTR_NAME' cannot appear here}}
118 void const_after_attr () ATTR_USE
const; // expected-error {{expected ';'}}
120 extern "C++" ATTR_USE
{ } // expected-error {{'ATTR_NAME' cannot appear here}}
121 ATTR_USE
extern "C++" { } // expected-error {{'ATTR_NAME' cannot appear here}}
122 ATTR_USE
template <typename T
> void before_template_attr (); // expected-error {{'ATTR_NAME' cannot appear here}}
123 ATTR_USE
namespace ns
{ int i
; } // expected-error {{'ATTR_NAME' cannot appear here}}
124 ATTR_USE
static_assert(true, ""); //expected-error {{'ATTR_NAME' cannot appear here}}
125 ATTR_USE
asm(""); // expected-error {{'ATTR_NAME' cannot appear here}}
127 ATTR_USE
using ns::i
; // expected-warning {{ISO C++}} \
128 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
129 ATTR_USE
using namespace ns
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
130 namespace ATTR_USE ns2
{} // expected-warning {{attributes on a namespace declaration are a C++17 extension}} \
131 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
133 using ATTR_USE
alignas(4)ATTR_USE
ns::i
; // expected-warning 2 {{ISO C++}} \
134 expected
-error
{{'ATTR_NAME' cannot appear here
}} \
135 expected
-error
{{'alignas' attribute only applies to variables
, data members
and tag types
}} \
136 expected
-warning
{{ISO C
++}} \
137 expected
-error
2 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
138 using ATTR_USE
alignas(4) ATTR_USE foobar
= int; // expected-error {{'ATTR_NAME' cannot appear here}} \
139 expected
-error
{{'alignas' attribute only applies to
}} \
140 expected
-error
2 {{'ATTR_NAME' only applies to function types
}}
142 ATTR_USE
using T
= int; // expected-error {{'ATTR_NAME' cannot appear here}}
143 using T ATTR_USE
= int; // expected-error {{'ATTR_NAME' only applies to function types}}
144 template<typename T
> using U ATTR_USE
= T
; // expected-error {{'ATTR_NAME' only applies to function types}}
145 using ns::i ATTR_USE
; // expected-warning {{ISO C++}} \
146 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
147 using ns::i ATTR_USE
, ns::i ATTR_USE
; // expected-warning 2 {{ISO C++}} \
148 expected
-warning
{{use of multiple declarators in a single
using declaration is a C
++17 extension
}} \
149 expected
-error
2 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
150 struct using_in_struct_base
{
151 typedef int i
, j
, k
, l
;
153 struct using_in_struct
: using_in_struct_base
{
154 ATTR_USE
using using_in_struct_base::i
; // expected-warning {{ISO C++}} \
155 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
156 using using_in_struct_base::j ATTR_USE
; // expected-warning {{ISO C++}} \
157 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
158 ATTR_USE
using using_in_struct_base::k ATTR_USE
, using_in_struct_base::l ATTR_USE
; // expected-warning 3 {{ISO C++}} \
159 expected
-warning
{{use of multiple declarators in a single
using declaration is a C
++17 extension
}} \
160 expected
-error
4 {{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
162 using ATTR_USE
ns::i
; // expected-warning {{ISO C++}} \
163 expected
-error
{{'ATTR_NAME' cannot appear here
}} \
164 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
165 using T ATTR_USE
= int; // expected-error {{'ATTR_NAME' only applies to function types}}
167 auto trailing() -> ATTR_USE
const int; // expected-error {{'ATTR_NAME' cannot appear here}}
168 auto trailing() -> const ATTR_USE
int; // expected-error {{'ATTR_NAME' cannot appear here}}
169 auto trailing() -> const int ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to function types}}
170 auto trailing_2() -> struct struct_attr ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to function types}}
175 template<typename
> struct Template
{};
177 // FIXME: Improve this diagnostic
178 struct ATTR_USE
N::S s
; // expected-error {{'ATTR_NAME' cannot appear here}}
179 struct ATTR_USE Template
<int> t
; // expected-error {{'ATTR_NAME' cannot appear here}}
180 struct ATTR_USE ::template Template
<int> u
; // expected-error {{'ATTR_NAME' cannot appear here}}
181 template struct ATTR_USE Template
<char>; // expected-error {{'ATTR_NAME' cannot appear here}}
182 template struct __attribute__((pure
)) Template
<std::size_t>; // We still allow GNU-style attributes here
183 template <> struct ATTR_USE Template
<void>; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
185 enum ATTR_USE E1
{}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
186 enum ATTR_USE E2
; // expected-error {{forbids forward references}} \
187 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
188 enum ATTR_USE E1
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
189 enum ATTR_USE E3
: int; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
190 enum ATTR_USE
{ // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
191 k_123 ATTR_USE
= 123 // expected-warning {{attributes on an enumerator declaration are a C++17 extension}} \
192 expected
-error
{{'ATTR_NAME' only applies to non
-K
&R
-style functions
}}
194 enum ATTR_USE E1 e
; // expected-error {{'ATTR_NAME' cannot appear here}}
195 enum ATTR_USE
class E4
{ }; // expected-error {{'ATTR_NAME' cannot appear here}}
196 enum struct ATTR_USE E5
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
197 enum E6
{} ATTR_USE
; // expected-error {{'ATTR_NAME' cannot appear here, place it after "enum" to apply it to the type declaration}}
200 friend int f
ATTR_USE (); // expected-error {{'ATTR_NAME' cannot appear here}} \
201 expected
-error
{{'ATTR_NAME' cannot be applied to a declaration
}}
202 friend int f2
ATTR_USE () {} // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
203 ATTR_USE
friend int g(); // expected-error {{'ATTR_NAME' cannot appear here}}
204 ATTR_USE
friend int h() { // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
206 ATTR_USE
friend int f3(), f4(), f5(); // expected-error {{'ATTR_NAME' cannot appear here}}
207 friend int f6
ATTR_USE (), f7
ATTR_USE (), f8
ATTR_USE (); // expected-error3 {{'ATTR_NAME' cannot appear here}} \
208 expected
-error
3 {{'ATTR_NAME' cannot be applied to a declaration
}}
209 friend class ATTR_USE C
; // expected-error {{'ATTR_NAME' cannot appear here}}
210 ATTR_USE
friend class D
; // expected-error {{'ATTR_NAME' cannot appear here}}
211 ATTR_USE
friend int; // expected-error {{'ATTR_NAME' cannot appear here}}
213 template<typename T
> void tmpl (T
) {}
214 template ATTR_USE
void tmpl(char); // expected-error {{'ATTR_NAME' cannot appear here}}
215 template void ATTR_USE
tmpl(short); // expected-error {{'ATTR_NAME' only applies to function types}}
219 ATTR_USE
; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
220 ATTR_USE
{ } // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
221 ATTR_USE
if (0) { } // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
222 ATTR_USE
for (;;); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
223 ATTR_USE
do { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
224 ATTR_USE
continue; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
226 ATTR_USE
while (0); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
228 ATTR_USE
switch (i
) { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
229 ATTR_USE
case 0: // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
230 ATTR_USE
default: // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
231 ATTR_USE
break; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
234 ATTR_USE
goto there
; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
235 ATTR_USE there
: // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
237 ATTR_USE
try { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
238 } ATTR_USE
catch (...) { // expected-error {{'ATTR_NAME' cannot appear here}}
241 void bar
ATTR_USE (ATTR_USE
int i
, ATTR_USE
int j
); // expected-error 2 {{'ATTR_NAME' only applies to function types}} \
242 expected
-error
{{'ATTR_NAME' cannot be applied to a declaration
}}
243 using FuncType
= void (ATTR_USE
int); // expected-error {{'ATTR_NAME' only applies to function types}}
244 void baz(ATTR_USE
...); // expected-error {{expected parameter declarator}}
246 ATTR_USE
return; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
251 new int[42]ATTR_USE
[5]ATTR_USE
{}; // expected-error {{'ATTR_NAME' only applies to function types}}
256 if (ATTR_USE
bool b
= true) { // expected-error {{'ATTR_NAME' only applies to function types}}
257 switch (ATTR_USE
int n
{ 42 }) { // expected-error {{'ATTR_NAME' only applies to function types}}
259 for (ATTR_USE
int n
= 0; ATTR_USE
char b
= n
< 5; ++b
) { // expected-error 2 {{'ATTR_NAME' only applies to function types}}
264 // An attribute can be applied to an expression-statement, such as the first
265 // statement in a for. But it can't be applied to a condition which is an
267 for (ATTR_USE x
= 0; ; ) {} // expected-error {{'ATTR_NAME' cannot appear here}}
268 for (; ATTR_USE x
< 5; ) {} // expected-error {{'ATTR_NAME' cannot appear here}}
269 while (ATTR_USE
bool k
{ false }) { // expected-error {{'ATTR_NAME' only applies to function types}}
271 while (ATTR_USE
true) { // expected-error {{'ATTR_NAME' cannot appear here}}
274 } while (ATTR_USE
false); // expected-error {{'ATTR_NAME' cannot appear here}}
276 for (ATTR_USE
int n
: { 1, 2, 3 }) { // expected-error {{'ATTR_NAME' only applies to function types}}
280 enum class __attribute__((visibility("hidden"))) SecretKeepers
{
281 one
, /* rest are deprecated */ two
, three
283 enum class ATTR_USE EvenMoreSecrets
{}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
285 // Forbid attributes on decl specifiers.
286 unsigned ATTR_USE
static int ATTR_USE v1
; // expected-error {{'ATTR_NAME' only applies to function types}} \
287 expected
-error
{{'ATTR_NAME' cannot appear here
}}
288 typedef ATTR_USE
unsigned long ATTR_USE v2
; // expected-error {{'ATTR_NAME' only applies to function types}} \
289 expected
-error
{{'ATTR_NAME' cannot appear here
}}
290 int ATTR_USE
foo(int ATTR_USE x
); // expected-error 2 {{'ATTR_NAME' only applies to function types}}
292 ATTR_USE
; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
295 A(ATTR_USE
int a
); // expected-error {{'ATTR_NAME' only applies to function types}}
297 A::A(ATTR_USE
int a
) {} // expected-error {{'ATTR_NAME' only applies to function types}}
299 template<typename T
> struct TemplateStruct
{};
300 class FriendClassesWithAttributes
{
301 // We allow GNU-style attributes here
302 template <class _Tp
, class _Alloc
> friend class __attribute__((__type_visibility__("default"))) vector
;
303 template <class _Tp
, class _Alloc
> friend class __declspec(code_seg("foo,whatever")) vector2
;
304 // But not C++11 ones
305 template <class _Tp
, class _Alloc
> friend class ATTR_USE vector3
; // expected-error {{'ATTR_NAME' cannot appear here}}
308 friend struct __attribute__((__type_visibility__("default"))) TemplateStruct
<FriendClassesWithAttributes
>;
309 friend struct __declspec(code_seg("foo,whatever")) TemplateStruct
<FriendClassesWithAttributes
>;
310 friend struct ATTR_USE TemplateStruct
<FriendClassesWithAttributes
>; // expected-error {{'ATTR_NAME' cannot appear here}}
313 // Check ordering: C++11 attributes must appear before GNU attributes.
316 int (ATTR_USE
__attribute__(()) int n
) // expected-error {{'ATTR_NAME' only applies to function types}}
321 int (*)(ATTR_USE
__attribute__(()) int n
) // expected-error {{'ATTR_NAME' only applies to function types}}
326 int (__attribute__(()) ATTR_USE
int n
) // expected-error {{'ATTR_NAME' cannot appear here}}
331 int (*)(__attribute__(()) ATTR_USE
int n
) // expected-error {{'ATTR_NAME' cannot appear here}}
336 namespace base_specs
{
338 struct B
: ATTR_USE A
{}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
339 struct C
: ATTR_USE
virtual A
{}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
340 struct D
: ATTR_USE
public virtual A
{}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
341 struct E
: public ATTR_USE
virtual A
{}; // expected-error {{'ATTR_NAME' cannot appear here}} \
342 expected
-error
{{'ATTR_NAME' cannot be applied to a base specifier
}}
343 struct F
: virtual ATTR_USE
public A
{}; // expected-error {{'ATTR_NAME' cannot appear here}} \
344 expected
-error
{{'ATTR_NAME' cannot be applied to a base specifier
}}
347 namespace ATTR_USE ns_attr
{}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}} \
348 expected
-warning
{{attributes on a
namespace declaration are a C
++17 extension
}}