xref: /llvm-project/clang/test/Parser/attr-order.cpp (revision 6cbd96e24c6a60cbc3dbb849d2ed7afc39c77a80)
1 // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-ignored-attributes -verify %s
2 
3 struct [[]] __attribute__((lockable)) __declspec(dllexport) A {}; // ok
4 struct [[]] __declspec(dllexport) __attribute__((lockable)) B {}; // ok
5 struct [[]] [[]] __declspec(dllexport) __attribute__((lockable)) C {}; // ok
6 struct __declspec(dllexport) [[]] __attribute__((lockable)) D {}; // ok
7 struct __declspec(dllexport) __attribute__((lockable)) [[]] E {}; // ok
8 struct __attribute__((lockable)) __declspec(dllexport) [[]] F {}; // ok
9 struct __attribute__((lockable)) [[]] __declspec(dllexport) G {}; // ok
10 struct [[]] __attribute__((lockable)) [[]] __declspec(dllexport) H {}; // ok
11 
12 [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void a(); // ok
13 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
14 [[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
15 
16 __declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // expected-error {{an attribute list cannot appear here}}
17 __declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // expected-error {{an attribute list cannot appear here}}
18 __attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // expected-error {{an attribute list cannot appear here}}
19 
20 __attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // ok
21 
22 [[noreturn]] __attribute__((cdecl))
23 [[]]
24 __declspec(dllexport) void h();
25 
26 template <int a>
27 __attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void i(); // ok
28 
29 template <int a>
30 [[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void j(); // ok
31 
32 template <int a>
33 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void k(); // ok
34 
35 extern "C" {
36   __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int l(int); // ok
37   [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int m(int); // ok
38 }
39 
40 extern "C" {
41   __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int n (int); // ok
42   __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] static int o (int x) { return x; }; // ok
43 }
44 
45 extern "C" __attribute__ ((__warn_unused_result__)) [[__maybe_unused__]] int p(int); // ok
46 extern "C" [[__maybe_unused__]] __attribute__ ((__warn_unused_result__)) int q(int); // ok
47