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
4 #define C2x(x) x: __has_c_attribute(x)
6 // CHECK: fallthrough: 201910L
9 // CHECK: __nodiscard__: 202003L
12 // CHECK: selectany: 0
13 C2x(selectany
); // Known attribute not supported in C mode
16 C2x(frobble
) // Unknown attribute
18 // CHECK: frobble::frobble: 0
19 C2x(frobble::frobble
) // Unknown vendor namespace
21 // CHECK: clang::annotate: 1
24 // CHECK: deprecated: 201904L
27 // CHECK: maybe_unused: 202106L
30 // CHECK: __gnu__::warn_unused_result: 202003L
31 C2x(__gnu__::warn_unused_result
)
33 // CHECK: gnu::__warn_unused_result__: 202003L
34 C2x(gnu::__warn_unused_result__
)
36 // Test that macro expansion of the builtin argument works.
39 #define CL clang::likely
42 #if __has_c_attribute(N)
45 // CHECK: int has_nodiscard;
47 #if __has_c_attribute(C::L)
48 int has_clang_likely_1
;
50 // CHECK: int has_clang_likely_1;
52 #if __has_c_attribute(clang::L)
53 int has_clang_likely_2
;
55 // CHECK: int has_clang_likely_2;
57 #if __has_c_attribute(C::likely)
58 int has_clang_likely_3
;
60 // CHECK: int has_clang_likely_3;
62 #if __has_c_attribute(CL)
63 int has_clang_likely_4
;
65 // CHECK: int has_clang_likely_4;
67 #define FUNCLIKE1(x) clang::x
68 #if __has_c_attribute(FUNCLIKE1(likely))
71 // CHECK: int funclike_1;
73 #define FUNCLIKE2(x) _Clang::x
74 #if __has_c_attribute(FUNCLIKE2(likely))
77 // CHECK: int funclike_2;