File: cxx0x-keyword-attributes.cpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (348 lines) | stat: -rw-r--r-- 21,560 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// RUN: sed -e "s@ATTR_USE@__arm_streaming@g" -e "s@ATTR_NAME@__arm_streaming@g" %s > %t
// 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
// RUN: sed -e "s@ATTR_USE@__arm_inout\(\"za\"\)@g" -e "s@ATTR_NAME@__arm_inout@g" %s > %t
// 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

// Need std::initializer_list
namespace std {
  typedef decltype(sizeof(int)) size_t;

  // libc++'s implementation
  template <class _E>
  class initializer_list
  {
    const _E* __begin_;
    size_t    __size_;

    initializer_list(const _E* __b, size_t __s)
      : __begin_(__b),
        __size_(__s)
    {}

  public:
    typedef _E        value_type;
    typedef const _E& reference;
    typedef const _E& const_reference;
    typedef size_t    size_type;

    typedef const _E* iterator;
    typedef const _E* const_iterator;

    initializer_list() : __begin_(nullptr), __size_(0) {}

    size_t    size()  const {return __size_;}
    const _E* begin() const {return __begin_;}
    const _E* end()   const {return __begin_ + __size_;}
  };
}


// Declaration syntax checks
ATTR_USE int before_attr; // expected-error {{'ATTR_NAME' only applies to function types}}
int ATTR_USE between_attr; // expected-error {{'ATTR_NAME' only applies to function types}}
const ATTR_USE int between_attr_2 = 0; // expected-error {{'ATTR_NAME' cannot appear here}}
int after_attr ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
int * ATTR_USE ptr_attr; // expected-error {{'ATTR_NAME' only applies to function types}}
int & ATTR_USE ref_attr = after_attr; // expected-error {{'ATTR_NAME' only applies to function types}}
int && ATTR_USE rref_attr = 0; // expected-error {{'ATTR_NAME' only applies to function types}}
int array_attr [1] ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
void fn_attr () ATTR_USE;
void noexcept_fn_attr () noexcept ATTR_USE;
struct MemberFnOrder {
  virtual void f() const volatile && noexcept ATTR_USE final = 0;
};
struct ATTR_USE struct_attr; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
class ATTR_USE class_attr {}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
union ATTR_USE union_attr; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum ATTR_USE E { }; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
namespace test_misplacement {
ATTR_USE struct struct_attr2;  // expected-error {{misplaced 'ATTR_NAME'}}
ATTR_USE class class_attr2; // expected-error {{misplaced 'ATTR_NAME'}}
ATTR_USE union union_attr2; // expected-error {{misplaced 'ATTR_NAME'}}
ATTR_USE enum  E2 { }; // expected-error {{misplaced 'ATTR_NAME'}}
}

// Checks attributes placed at wrong syntactic locations of class specifiers.
class ATTR_USE ATTR_USE // expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
  attr_after_class_name_decl ATTR_USE ATTR_USE; // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                                 expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}

class ATTR_USE ATTR_USE // expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
 attr_after_class_name_definition ATTR_USE ATTR_USE ATTR_USE{}; // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                                                        expected-error 3 {{'ATTR_NAME' only applies to non-K&R-style functions}}

class ATTR_USE c {}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
class c ATTR_USE ATTR_USE x; // expected-error 2 {{'ATTR_NAME' only applies to function types}}
class c ATTR_USE ATTR_USE y ATTR_USE ATTR_USE; // expected-error 4 {{'ATTR_NAME' only applies to function types}}
class c final [(int){0}];

class base {};
class ATTR_USE ATTR_USE final_class // expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
  ATTR_USE alignas(float) final // expected-error {{'ATTR_NAME' cannot appear here}} \
                                          expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
  ATTR_USE alignas(float) ATTR_USE alignas(float): base{}; // expected-error {{'ATTR_NAME' cannot appear here}}

class ATTR_USE ATTR_USE final_class_another // expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
  ATTR_USE ATTR_USE alignas(16) final // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                       expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
  ATTR_USE ATTR_USE alignas(16) ATTR_USE{}; // expected-error {{'ATTR_NAME' cannot appear here}}

class after_class_close {} ATTR_USE; // expected-error {{'ATTR_NAME' cannot appear here, place it after "class" to apply it to the type declaration}}

class C {};

ATTR_USE struct with_init_declarators {} init_declarator; // expected-error {{'ATTR_NAME' only applies to function types}}
ATTR_USE struct no_init_declarators; // expected-error {{misplaced 'ATTR_NAME'}}
template<typename> ATTR_USE struct no_init_declarators_template; // expected-error {{'ATTR_NAME' cannot appear here}}
void fn_with_structs() {
  ATTR_USE struct with_init_declarators {} init_declarator; // expected-error {{'ATTR_NAME' only applies to function types}}
  ATTR_USE struct no_init_declarators; // expected-error {{'ATTR_NAME' cannot appear here}}
}
ATTR_USE; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
struct ctordtor {
  ATTR_USE ctordtor ATTR_USE () ATTR_USE; // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
  ctordtor (C) ATTR_USE;
  ATTR_USE ~ctordtor ATTR_USE () ATTR_USE; // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
};
ATTR_USE ctordtor::ctordtor ATTR_USE () ATTR_USE {} // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
ATTR_USE ctordtor::ctordtor (C) ATTR_USE try {} catch (...) {} // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
ATTR_USE ctordtor::~ctordtor ATTR_USE () ATTR_USE {} // expected-error 2 {{'ATTR_NAME' cannot be applied to a declaration}}
extern "C++" ATTR_USE int extern_attr; // expected-error {{'ATTR_NAME' only applies to function types}}
template <typename T> ATTR_USE void template_attr (); // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
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}}

int (paren_attr) ATTR_USE; // expected-error {{'ATTR_NAME' cannot appear here}}
unsigned ATTR_USE int attr_in_decl_spec; // expected-error {{'ATTR_NAME' cannot appear here}}
unsigned ATTR_USE int ATTR_USE const double_decl_spec = 0; // expected-error 2 {{'ATTR_NAME' cannot appear here}}
class foo {
  void const_after_attr () ATTR_USE const; // expected-error {{expected ';'}}
};
extern "C++" ATTR_USE { } // expected-error {{'ATTR_NAME' cannot appear here}}
ATTR_USE extern "C++" { } // expected-error {{'ATTR_NAME' cannot appear here}}
ATTR_USE template <typename T> void before_template_attr (); // expected-error {{'ATTR_NAME' cannot appear here}}
ATTR_USE namespace ns { int i; } // expected-error {{'ATTR_NAME' cannot appear here}}
ATTR_USE static_assert(true, ""); //expected-error {{'ATTR_NAME' cannot appear here}}
ATTR_USE asm(""); // expected-error {{'ATTR_NAME' cannot appear here}}

ATTR_USE using ns::i; // expected-warning {{ISO C++}} \
                                expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
ATTR_USE using namespace ns; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
namespace ATTR_USE ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}} \
                                    expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}

using ATTR_USE alignas(4)ATTR_USE ns::i;          // expected-warning 2 {{ISO C++}} \
                                                                   expected-error {{'ATTR_NAME' cannot appear here}} \
                                                                   expected-error {{'alignas' attribute only applies to variables, data members and tag types}} \
                                                                   expected-warning {{ISO C++}} \
                                                                   expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
using ATTR_USE alignas(4) ATTR_USE foobar = int; // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                                  expected-error {{'alignas' attribute only applies to}} \
                                                                  expected-error 2 {{'ATTR_NAME' only applies to function types}}

ATTR_USE using T = int; // expected-error {{'ATTR_NAME' cannot appear here}}
using T ATTR_USE = int; // expected-error {{'ATTR_NAME' only applies to function types}}
template<typename T> using U ATTR_USE = T; // expected-error {{'ATTR_NAME' only applies to function types}}
using ns::i ATTR_USE; // expected-warning {{ISO C++}} \
                                expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
using ns::i ATTR_USE, ns::i ATTR_USE; // expected-warning 2 {{ISO C++}} \
                                                       expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}} \
                                                       expected-error 2 {{'ATTR_NAME' only applies to non-K&R-style functions}}
struct using_in_struct_base {
  typedef int i, j, k, l;
};
struct using_in_struct : using_in_struct_base {
  ATTR_USE using using_in_struct_base::i; // expected-warning {{ISO C++}} \
                                                    expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
  using using_in_struct_base::j ATTR_USE; // expected-warning {{ISO C++}} \
                                                    expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
  ATTR_USE using using_in_struct_base::k ATTR_USE, using_in_struct_base::l ATTR_USE; // expected-warning 3 {{ISO C++}} \
                                                                                                             expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}} \
                                                                                                             expected-error 4 {{'ATTR_NAME' only applies to non-K&R-style functions}}
};
using ATTR_USE ns::i; // expected-warning {{ISO C++}} \
                                expected-error {{'ATTR_NAME' cannot appear here}} \
                                expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
using T ATTR_USE = int; // expected-error {{'ATTR_NAME' only applies to function types}}

auto trailing() -> ATTR_USE const int; // expected-error {{'ATTR_NAME' cannot appear here}}
auto trailing() -> const ATTR_USE int; // expected-error {{'ATTR_NAME' cannot appear here}}
auto trailing() -> const int ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}
auto trailing_2() -> struct struct_attr ATTR_USE; // expected-error {{'ATTR_NAME' only applies to function types}}

namespace N {
  struct S {};
};
template<typename> struct Template {};

// FIXME: Improve this diagnostic
struct ATTR_USE N::S s; // expected-error {{'ATTR_NAME' cannot appear here}}
struct ATTR_USE Template<int> t; // expected-error {{'ATTR_NAME' cannot appear here}}
struct ATTR_USE ::template Template<int> u; // expected-error {{'ATTR_NAME' cannot appear here}}
template struct ATTR_USE Template<char>; // expected-error {{'ATTR_NAME' cannot appear here}}
template struct __attribute__((pure)) Template<std::size_t>; // We still allow GNU-style attributes here
template <> struct ATTR_USE Template<void>; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}

enum ATTR_USE E1 {}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum ATTR_USE E2; // expected-error {{forbids forward references}} \
                            expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum ATTR_USE E1; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum ATTR_USE E3 : int; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum ATTR_USE { // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
  k_123 ATTR_USE = 123 // expected-warning {{attributes on an enumerator declaration are a C++17 extension}} \
                                 expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
};
enum ATTR_USE E1 e; // expected-error {{'ATTR_NAME' cannot appear here}}
enum ATTR_USE class E4 { }; // expected-error {{'ATTR_NAME' cannot appear here}}
enum struct ATTR_USE E5; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}
enum E6 {} ATTR_USE; // expected-error {{'ATTR_NAME' cannot appear here, place it after "enum" to apply it to the type declaration}}

struct S {
  friend int f ATTR_USE (); // expected-error {{'ATTR_NAME' cannot appear here}} \
                                      expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
  friend int f2 ATTR_USE () {} // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
  ATTR_USE friend int g(); // expected-error {{'ATTR_NAME' cannot appear here}}
  ATTR_USE friend int h() { // expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
  }
  ATTR_USE friend int f3(), f4(), f5(); // expected-error {{'ATTR_NAME' cannot appear here}}
  friend int f6 ATTR_USE (), f7 ATTR_USE (), f8 ATTR_USE (); // expected-error3 {{'ATTR_NAME' cannot appear here}} \
                                                                                     expected-error 3 {{'ATTR_NAME' cannot be applied to a declaration}}
  friend class ATTR_USE C; // expected-error {{'ATTR_NAME' cannot appear here}}
  ATTR_USE friend class D; // expected-error {{'ATTR_NAME' cannot appear here}}
  ATTR_USE friend int; // expected-error {{'ATTR_NAME' cannot appear here}}
};
template<typename T> void tmpl (T) {}
template ATTR_USE void tmpl(char); // expected-error {{'ATTR_NAME' cannot appear here}}
template void ATTR_USE tmpl(short); // expected-error {{'ATTR_NAME' only applies to function types}}

// Statement tests
void foo () {
  ATTR_USE ; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  ATTR_USE { } // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  ATTR_USE if (0) { } // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  ATTR_USE for (;;); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  ATTR_USE do { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
    ATTR_USE continue; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  } while (0);
  ATTR_USE while (0); // expected-error {{'ATTR_NAME' cannot be applied to a statement}}

  ATTR_USE switch (i) { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
    ATTR_USE case 0: // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
    ATTR_USE default: // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
      ATTR_USE break; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  }

  ATTR_USE goto there; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  ATTR_USE there: // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}

  ATTR_USE try { // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
  } ATTR_USE catch (...) { // expected-error {{'ATTR_NAME' cannot appear here}}
  }

  void bar ATTR_USE (ATTR_USE int i, ATTR_USE int j); // expected-error 2 {{'ATTR_NAME' only applies to function types}} \
                                                                              expected-error {{'ATTR_NAME' cannot be applied to a declaration}}
  using FuncType = void (ATTR_USE int); // expected-error {{'ATTR_NAME' only applies to function types}}
  void baz(ATTR_USE...); // expected-error {{expected parameter declarator}}

  ATTR_USE return; // expected-error {{'ATTR_NAME' cannot be applied to a statement}}
}

// Expression tests
void bar () {
  new int[42]ATTR_USE[5]ATTR_USE{}; // expected-error {{'ATTR_NAME' only applies to function types}}
}

// Condition tests
void baz () {
  if (ATTR_USE bool b = true) { // expected-error {{'ATTR_NAME' only applies to function types}}
    switch (ATTR_USE int n { 42 }) { // expected-error {{'ATTR_NAME' only applies to function types}}
    default:
      for (ATTR_USE int n = 0; ATTR_USE char b = n < 5; ++b) { // expected-error 2 {{'ATTR_NAME' only applies to function types}}
      }
    }
  }
  int x;
  // An attribute can be applied to an expression-statement, such as the first
  // statement in a for. But it can't be applied to a condition which is an
  // expression.
  for (ATTR_USE x = 0; ; ) {} // expected-error {{'ATTR_NAME' cannot appear here}}
  for (; ATTR_USE x < 5; ) {} // expected-error {{'ATTR_NAME' cannot appear here}}
  while (ATTR_USE bool k { false }) { // expected-error {{'ATTR_NAME' only applies to function types}}
  }
  while (ATTR_USE true) { // expected-error {{'ATTR_NAME' cannot appear here}}
  }
  do {
  } while (ATTR_USE false); // expected-error {{'ATTR_NAME' cannot appear here}}

  for (ATTR_USE int n : { 1, 2, 3 }) { // expected-error {{'ATTR_NAME' only applies to function types}}
  }
}

enum class __attribute__((visibility("hidden"))) SecretKeepers {
  one, /* rest are deprecated */ two, three
};
enum class ATTR_USE EvenMoreSecrets {}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}

// Forbid attributes on decl specifiers.
unsigned ATTR_USE static int ATTR_USE v1; // expected-error {{'ATTR_NAME' only applies to function types}} \
           expected-error {{'ATTR_NAME' cannot appear here}}
typedef ATTR_USE unsigned long ATTR_USE v2; // expected-error {{'ATTR_NAME' only applies to function types}} \
          expected-error {{'ATTR_NAME' cannot appear here}}
int ATTR_USE foo(int ATTR_USE x); // expected-error 2 {{'ATTR_NAME' only applies to function types}}

ATTR_USE; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}}

class A {
  A(ATTR_USE int a); // expected-error {{'ATTR_NAME' only applies to function types}}
};
A::A(ATTR_USE int a) {} // expected-error {{'ATTR_NAME' only applies to function types}}

template<typename T> struct TemplateStruct {};
class FriendClassesWithAttributes {
  // We allow GNU-style attributes here
  template <class _Tp, class _Alloc> friend class __attribute__((__type_visibility__("default"))) vector;
  template <class _Tp, class _Alloc> friend class __declspec(code_seg("foo,whatever")) vector2;
  // But not C++11 ones
  template <class _Tp, class _Alloc> friend class ATTR_USE vector3;                                         // expected-error {{'ATTR_NAME' cannot appear here}}

  // Also allowed
  friend struct __attribute__((__type_visibility__("default"))) TemplateStruct<FriendClassesWithAttributes>;
  friend struct __declspec(code_seg("foo,whatever")) TemplateStruct<FriendClassesWithAttributes>;
  friend struct ATTR_USE TemplateStruct<FriendClassesWithAttributes>;                                       // expected-error {{'ATTR_NAME' cannot appear here}}
};

// Check ordering: C++11 attributes must appear before GNU attributes.
class Ordering {
  void f1(
    int (ATTR_USE __attribute__(()) int n) // expected-error {{'ATTR_NAME' only applies to function types}}
  ) {
  }

  void f2(
      int (*)(ATTR_USE __attribute__(()) int n) // expected-error {{'ATTR_NAME' only applies to function types}}
  ) {
  }

  void f3(
    int (__attribute__(()) ATTR_USE int n) // expected-error {{'ATTR_NAME' cannot appear here}}
  ) {
  }

  void f4(
      int (*)(__attribute__(()) ATTR_USE int n) // expected-error {{'ATTR_NAME' cannot appear here}}
  ) {
  }
};

namespace base_specs {
struct A {};
struct B : ATTR_USE A {}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
struct C : ATTR_USE virtual A {}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
struct D : ATTR_USE public virtual A {}; // expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
struct E : public ATTR_USE virtual A {}; // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                   expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
struct F : virtual ATTR_USE public A {}; // expected-error {{'ATTR_NAME' cannot appear here}} \
                                                   expected-error {{'ATTR_NAME' cannot be applied to a base specifier}}
}

namespace ATTR_USE ns_attr {}; // expected-error {{'ATTR_NAME' only applies to non-K&R-style functions}} \
                                         expected-warning {{attributes on a namespace declaration are a C++17 extension}}