1 // RUN: %clang_cc1 -std=c11 -E -P %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
4 #define C2x(x) x: __has_c_attribute(x)
6 // CHECK: fallthrough: 201910L
9 // CHECK: __nodiscard__: 202003L
12 // CHECK: warn_unused_result: 0
13 C2x(warn_unused_result
)
15 // CHECK: gnu::warn_unused_result: 1
16 C2x(gnu::warn_unused_result
)
18 // CHECK: clang::warn_unused_result: 0
19 C2x(clang::warn_unused_result
)
21 // CHECK: selectany: 0
22 C2x(selectany
); // Known attribute not supported in C mode
25 C2x(frobble
) // Unknown attribute
27 // CHECK: frobble::frobble: 0
28 C2x(frobble::frobble
) // Unknown vendor namespace
30 // CHECK: clang::annotate: 1
33 // CHECK: deprecated: 201904L
36 // CHECK: maybe_unused: 202106L
39 // CHECK: __gnu__::warn_unused_result: 1
40 C2x(__gnu__::warn_unused_result
)
42 // CHECK: gnu::__warn_unused_result__: 1
43 C2x(gnu::__warn_unused_result__
)
45 // Test that macro expansion of the builtin argument works.
48 #define CL clang::likely
51 #if __has_c_attribute(N)
54 // CHECK: int has_nodiscard;
56 #if __has_c_attribute(C::L)
57 int has_clang_likely_1
;
59 // CHECK: int has_clang_likely_1;
61 #if __has_c_attribute(clang::L)
62 int has_clang_likely_2
;
64 // CHECK: int has_clang_likely_2;
66 #if __has_c_attribute(C::likely)
67 int has_clang_likely_3
;
69 // CHECK: int has_clang_likely_3;
71 #if __has_c_attribute(CL)
72 int has_clang_likely_4
;
74 // CHECK: int has_clang_likely_4;
76 #define FUNCLIKE1(x) clang::x
77 #if __has_c_attribute(FUNCLIKE1(likely))
80 // CHECK: int funclike_1;
82 #define FUNCLIKE2(x) _Clang::x
83 #if __has_c_attribute(FUNCLIKE2(likely))
86 // CHECK: int funclike_2;