From ef2c8274dfa216078436c6acfe0274a43a737242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 8 Feb 2022 11:12:28 +0100 Subject: [PATCH] [clang] Add test for C++ DR2390 DR2390 clarifies that the argument to __has_cpp_attribute() needs to be macro-expanded. Clang already supports this and tests it explicitly in clang/test/Preprocessor/has_attribute.cpp. Copy the test over to clang/test/CXX/drs/ so the make_cxx_drs script picks it up. Differential Revision: https://reviews.llvm.org/D119230 --- clang/test/CXX/drs/dr2390.cpp | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 clang/test/CXX/drs/dr2390.cpp diff --git a/clang/test/CXX/drs/dr2390.cpp b/clang/test/CXX/drs/dr2390.cpp new file mode 100644 index 000000000000..d8ab1e9a1b38 --- /dev/null +++ b/clang/test/CXX/drs/dr2390.cpp @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s + +// dr2390: yes + +namespace PR48462 { +// Test that macro expansion of the builtin argument works. +#define C clang +#define F fallthrough +#define CF clang::fallthrough + +#if __has_cpp_attribute(F) +int has_fallthrough; +#endif +// CHECK: int has_fallthrough; + +#if __has_cpp_attribute(C::F) +int has_clang_fallthrough_1; +#endif +// CHECK: int has_clang_fallthrough_1; + +#if __has_cpp_attribute(clang::F) +int has_clang_fallthrough_2; +#endif +// CHECK: int has_clang_fallthrough_2; + +#if __has_cpp_attribute(C::fallthrough) +int has_clang_fallthrough_3; +#endif +// CHECK: int has_clang_fallthrough_3; + +#if __has_cpp_attribute(CF) +int has_clang_fallthrough_4; +#endif +// CHECK: int has_clang_fallthrough_4; + +#define FUNCLIKE1(x) clang::x +#if __has_cpp_attribute(FUNCLIKE1(fallthrough)) +int funclike_1; +#endif +// CHECK: int funclike_1; + +#define FUNCLIKE2(x) _Clang::x +#if __has_cpp_attribute(FUNCLIKE2(fallthrough)) +int funclike_2; +#endif +// CHECK: int funclike_2; +} // namespace PR48462