[libcxx-commits] [libcxx] 84d4037 - Reapply "[libc++] Fix tests for clang::no_specializations for C++17 and C++20"
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 25 01:26:46 PST 2025
Author: Nikolas Klauser
Date: 2025-01-25T10:26:15+01:00
New Revision: 84d4037488f5b366e76be4fe723e0de7aeee264d
URL: https://github.com/llvm/llvm-project/commit/84d4037488f5b366e76be4fe723e0de7aeee264d
DIFF: https://github.com/llvm/llvm-project/commit/84d4037488f5b366e76be4fe723e0de7aeee264d.diff
LOG: Reapply "[libc++] Fix tests for clang::no_specializations for C++17 and C++20"
The missing diagnostic pragmas have been added.
This reverts commit 8a6b44bf4cfe5df3db687a6b9519e99dbce8cf54.
Added:
Modified:
libcxx/include/__type_traits/result_of.h
libcxx/test/libcxx/ranges/no_specializations.verify.cpp
libcxx/test/libcxx/type_traits/no_specializations.verify.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__type_traits/result_of.h b/libcxx/include/__type_traits/result_of.h
index 217ca70b4cd207..e6adec7f9c9783 100644
--- a/libcxx/include/__type_traits/result_of.h
+++ b/libcxx/include/__type_traits/result_of.h
@@ -22,10 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
template <class _Callable>
-struct _LIBCPP_DEPRECATED_IN_CXX17 result_of;
+struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS result_of;
+_LIBCPP_DIAGNOSTIC_PUSH
+#if __has_warning("-Winvalid-specialization")
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
+#endif
template <class _Fp, class... _Args>
struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
+_LIBCPP_DIAGNOSTIC_POP
# if _LIBCPP_STD_VER >= 14
template <class _Tp>
diff --git a/libcxx/test/libcxx/ranges/no_specializations.verify.cpp b/libcxx/test/libcxx/ranges/no_specializations.verify.cpp
index 69d458a9205583..489e3a6a73744f 100644
--- a/libcxx/test/libcxx/ranges/no_specializations.verify.cpp
+++ b/libcxx/test/libcxx/ranges/no_specializations.verify.cpp
@@ -13,7 +13,9 @@
#include <ranges>
-#if !__has_warning("-Winvalid-specialization")
+#include "test_macros.h"
+
+#if !__has_warning("-Winvalid-specialization") || TEST_STD_VER <= 20
// expected-no-diagnostics
#else
struct S {};
diff --git a/libcxx/test/libcxx/type_traits/no_specializations.verify.cpp b/libcxx/test/libcxx/type_traits/no_specializations.verify.cpp
index e6d960667e8c0c..807d01e381b492 100644
--- a/libcxx/test/libcxx/type_traits/no_specializations.verify.cpp
+++ b/libcxx/test/libcxx/type_traits/no_specializations.verify.cpp
@@ -36,15 +36,22 @@ SPECIALIZE_TRAIT(make_unsigned); // expected-error {{cannot be specialize
SPECIALIZE_TRAIT(remove_all_extents); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_const); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_cv); // expected-error {{cannot be specialized}}
-SPECIALIZE_TRAIT(remove_cvref); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_extent); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_pointer); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_reference); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(remove_volatile); // expected-error {{cannot be specialized}}
-SPECIALIZE_TRAIT(type_identity); // expected-error {{cannot be specialized}}
SPECIALIZE_TRAIT(underlying_type); // expected-error {{cannot be specialized}}
-SPECIALIZE_TRAIT(unwrap_reference); // expected-error {{cannot be specialized}}
-SPECIALIZE_TRAIT(unwrap_ref_decay); // expected-error {{cannot be specialized}}
+
+# if TEST_STD_VER <= 17
+SPECIALIZE_TRAIT(result_of); // expected-error {{cannot be specialized}}
+# endif
+
+# if TEST_STD_VER >= 20
+SPECIALIZE_TRAIT(remove_cvref); // expected-error {{cannot be specialized}}
+SPECIALIZE_TRAIT(type_identity); // expected-error {{cannot be specialized}}
+SPECIALIZE_TRAIT(unwrap_reference); // expected-error {{cannot be specialized}}
+SPECIALIZE_TRAIT(unwrap_ref_decay); // expected-error {{cannot be specialized}}
+# endif
# undef SPECIALIZE_TRAIT
# define SPECIALIZE_UTT(Trait) \
@@ -96,7 +103,6 @@ SPECIALIZE_UTT(is_move_assignable); // expected-error 2 {{cannot
SPECIALIZE_UTT(is_move_constructible); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_BTT(is_nothrow_assignable); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_nothrow_constructible); // expected-error 2 {{cannot be specialized}}
-SPECIALIZE_BTT(is_nothrow_convertible); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_nothrow_copy_assignable); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_nothrow_copy_constructible); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_nothrow_default_constructible); // expected-error 2 {{cannot be specialized}}
@@ -130,7 +136,6 @@ SPECIALIZE_UTT(is_trivially_default_constructible); // expected-error 2 {{cannot
SPECIALIZE_UTT(is_trivially_destructible); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_trivially_move_assignable); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_trivially_move_constructible); // expected-error 2 {{cannot be specialized}}
-SPECIALIZE_UTT(is_unbounded_array); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_union); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_unsigned); // expected-error 2 {{cannot be specialized}}
SPECIALIZE_UTT(is_void); // expected-error 2 {{cannot be specialized}}
@@ -140,11 +145,12 @@ SPECIALIZE_UTT(rank); // expected-error 2 {{cannot
# if TEST_STD_VER <= 17
SPECIALIZE_UTT(is_literal_type); // expected-error 2 {{cannot be specialized}}
-SPECIALIZE_UTT(result_of); // expected-error 2 {{cannot be specialized}}
# endif
# if TEST_STD_VER >= 20
-SPECIALIZE_UTT(is_bounded_array); // expected-error 2 {{cannot be specialized}}
+SPECIALIZE_UTT(is_bounded_array); // expected-error 2 {{cannot be specialized}}
+SPECIALIZE_BTT(is_nothrow_convertible); // expected-error 2 {{cannot be specialized}}
+SPECIALIZE_UTT(is_unbounded_array); // expected-error 2 {{cannot be specialized}}
# endif
# if TEST_STD_VER >= 23
@@ -171,6 +177,8 @@ struct std::conditional<true, S, S>; // expected-error {{cannot be specialized}}
template <>
struct std::enable_if<true, S>; // expected-error {{cannot be specialized}}
+#if TEST_STD_VER >= 20
template <>
struct std::integral_constant<S, {}>; // expected-error {{cannot be specialized}}
#endif
+#endif
More information about the libcxx-commits
mailing list