1 // RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E -P %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
3 
4 #define C2x(x) x: __has_c_attribute(x)
5 
6 // CHECK: fallthrough: 201904L
7 C2x(fallthrough)
8 
9 // CHECK: __nodiscard__: 201904L
10 C2x(__nodiscard__)
11 
12 // CHECK: selectany: 0
13 C2x(selectany); // Known attribute not supported in C mode
14 
15 // CHECK: frobble: 0
16 C2x(frobble) // Unknown attribute
17 
18 // CHECK: frobble::frobble: 0
19 C2x(frobble::frobble) // Unknown vendor namespace
20 
21 // CHECK: clang::annotate: 1
22 C2x(clang::annotate)
23 
24 // CHECK: deprecated: 201904L
25 C2x(deprecated)
26 
27 // CHECK: maybe_unused: 201904L
28 C2x(maybe_unused)
29 
30 // CHECK: __gnu__::warn_unused_result: 201904L
31 C2x(__gnu__::warn_unused_result)
32 
33 // CHECK: gnu::__warn_unused_result__: 201904L
34 C2x(gnu::__warn_unused_result__)
35 
36 // Test that macro expansion of the builtin argument works.
37 #define C clang
38 #define L likely
39 #define CL clang::likely
40 #define N nodiscard
41 
42 #if __has_c_attribute(N)
43 int has_nodiscard;
44 #endif
45 // CHECK: int has_nodiscard;
46 
47 #if __has_c_attribute(C::L)
48 int has_clang_likely_1;
49 #endif
50 // CHECK: int has_clang_likely_1;
51 
52 #if __has_c_attribute(clang::L)
53 int has_clang_likely_2;
54 #endif
55 // CHECK: int has_clang_likely_2;
56 
57 #if __has_c_attribute(C::likely)
58 int has_clang_likely_3;
59 #endif
60 // CHECK: int has_clang_likely_3;
61 
62 #if __has_c_attribute(CL)
63 int has_clang_likely_4;
64 #endif
65 // CHECK: int has_clang_likely_4;
66 
67 #define FUNCLIKE1(x) clang::x
68 #if __has_c_attribute(FUNCLIKE1(likely))
69 int funclike_1;
70 #endif
71 // CHECK: int funclike_1;
72 
73 #define FUNCLIKE2(x) _Clang::x
74 #if __has_c_attribute(FUNCLIKE2(likely))
75 int funclike_2;
76 #endif
77 // CHECK: int funclike_2;
78