107 lines · c
1// RUN: %clang_cc1 -std=c11 -E -P %s -o - | FileCheck %s2// RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s3 4#define C2x(x) x: __has_c_attribute(x)5 6// CHECK: fallthrough: 201910L7C2x(fallthrough)8 9// CHECK: __nodiscard__: 202003L10C2x(__nodiscard__)11 12// CHECK: warn_unused_result: 013C2x(warn_unused_result)14 15// CHECK: gnu::warn_unused_result: 116C2x(gnu::warn_unused_result)17 18// CHECK: clang::warn_unused_result: 019C2x(clang::warn_unused_result)20 21// CHECK: selectany: 022C2x(selectany); // Known attribute not supported in C mode23 24// CHECK: frobble: 025C2x(frobble) // Unknown attribute26 27// CHECK: frobble::frobble: 028C2x(frobble::frobble) // Unknown vendor namespace29 30// CHECK: clang::annotate: 131C2x(clang::annotate)32 33// CHECK: deprecated: 201904L34C2x(deprecated)35 36// CHECK: maybe_unused: 202106L37C2x(maybe_unused)38 39// CHECK: __gnu__::warn_unused_result: 140C2x(__gnu__::warn_unused_result)41 42// CHECK: gnu::__warn_unused_result__: 143C2x(gnu::__warn_unused_result__)44 45// Test that macro expansion of the builtin argument works.46#define C clang47#define L likely48#define CL clang::likely49#define N nodiscard50 51#if __has_c_attribute(N)52int has_nodiscard;53#endif54// CHECK: int has_nodiscard;55 56#if __has_c_attribute(C::L)57int has_clang_likely_1;58#endif59// CHECK: int has_clang_likely_1;60 61#if __has_c_attribute(clang::L)62int has_clang_likely_2;63#endif64// CHECK: int has_clang_likely_2;65 66#if __has_c_attribute(C::likely)67int has_clang_likely_3;68#endif69// CHECK: int has_clang_likely_3;70 71#if __has_c_attribute(CL)72int has_clang_likely_4;73#endif74// CHECK: int has_clang_likely_4;75 76#define FUNCLIKE1(x) clang::x77#if __has_c_attribute(FUNCLIKE1(likely))78int funclike_1;79#endif80// CHECK: int funclike_1;81 82#define FUNCLIKE2(x) _Clang::x83#if __has_c_attribute(FUNCLIKE2(likely))84int funclike_2;85#endif86// CHECK: int funclike_2;87 88#if __has_c_attribute(CL\89)90int has_clang_likely_5;91#endif92// CHECK: int has_clang_likely_5;93 94#define CL_2 clang::\95likely96 97#if __has_c_attribute(CL_2)98int has_clang_likely_6;99#endif100// CHECK: int has_clang_likely_6;101 102#if __has_c_attribute(CL_2\103)104int has_clang_likely_7;105#endif106// CHECK: int has_clang_likely_7;107