Skip to content

Commit 84d4037

Browse files
committed
Reapply "[libc++] Fix tests for clang::no_specializations for C++17 and C++20"
The missing diagnostic pragmas have been added. This reverts commit 8a6b44b.
1 parent 72918fd commit 84d4037

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

libcxx/include/__type_traits/result_of.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222

2323
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2424
template <class _Callable>
25-
struct _LIBCPP_DEPRECATED_IN_CXX17 result_of;
25+
struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS result_of;
2626

27+
_LIBCPP_DIAGNOSTIC_PUSH
28+
#if __has_warning("-Winvalid-specialization")
29+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
30+
#endif
2731
template <class _Fp, class... _Args>
2832
struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
33+
_LIBCPP_DIAGNOSTIC_POP
2934

3035
# if _LIBCPP_STD_VER >= 14
3136
template <class _Tp>

libcxx/test/libcxx/ranges/no_specializations.verify.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
#include <ranges>
1515

16-
#if !__has_warning("-Winvalid-specialization")
16+
#include "test_macros.h"
17+
18+
#if !__has_warning("-Winvalid-specialization") || TEST_STD_VER <= 20
1719
// expected-no-diagnostics
1820
#else
1921
struct S {};

libcxx/test/libcxx/type_traits/no_specializations.verify.cpp

+16-8
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,22 @@ SPECIALIZE_TRAIT(make_unsigned); // expected-error {{cannot be specialize
3636
SPECIALIZE_TRAIT(remove_all_extents); // expected-error {{cannot be specialized}}
3737
SPECIALIZE_TRAIT(remove_const); // expected-error {{cannot be specialized}}
3838
SPECIALIZE_TRAIT(remove_cv); // expected-error {{cannot be specialized}}
39-
SPECIALIZE_TRAIT(remove_cvref); // expected-error {{cannot be specialized}}
4039
SPECIALIZE_TRAIT(remove_extent); // expected-error {{cannot be specialized}}
4140
SPECIALIZE_TRAIT(remove_pointer); // expected-error {{cannot be specialized}}
4241
SPECIALIZE_TRAIT(remove_reference); // expected-error {{cannot be specialized}}
4342
SPECIALIZE_TRAIT(remove_volatile); // expected-error {{cannot be specialized}}
44-
SPECIALIZE_TRAIT(type_identity); // expected-error {{cannot be specialized}}
4543
SPECIALIZE_TRAIT(underlying_type); // expected-error {{cannot be specialized}}
46-
SPECIALIZE_TRAIT(unwrap_reference); // expected-error {{cannot be specialized}}
47-
SPECIALIZE_TRAIT(unwrap_ref_decay); // expected-error {{cannot be specialized}}
44+
45+
# if TEST_STD_VER <= 17
46+
SPECIALIZE_TRAIT(result_of); // expected-error {{cannot be specialized}}
47+
# endif
48+
49+
# if TEST_STD_VER >= 20
50+
SPECIALIZE_TRAIT(remove_cvref); // expected-error {{cannot be specialized}}
51+
SPECIALIZE_TRAIT(type_identity); // expected-error {{cannot be specialized}}
52+
SPECIALIZE_TRAIT(unwrap_reference); // expected-error {{cannot be specialized}}
53+
SPECIALIZE_TRAIT(unwrap_ref_decay); // expected-error {{cannot be specialized}}
54+
# endif
4855

4956
# undef SPECIALIZE_TRAIT
5057
# define SPECIALIZE_UTT(Trait) \
@@ -96,7 +103,6 @@ SPECIALIZE_UTT(is_move_assignable); // expected-error 2 {{cannot
96103
SPECIALIZE_UTT(is_move_constructible); // expected-error 2 {{cannot be specialized}}
97104
SPECIALIZE_BTT(is_nothrow_assignable); // expected-error 2 {{cannot be specialized}}
98105
SPECIALIZE_UTT(is_nothrow_constructible); // expected-error 2 {{cannot be specialized}}
99-
SPECIALIZE_BTT(is_nothrow_convertible); // expected-error 2 {{cannot be specialized}}
100106
SPECIALIZE_UTT(is_nothrow_copy_assignable); // expected-error 2 {{cannot be specialized}}
101107
SPECIALIZE_UTT(is_nothrow_copy_constructible); // expected-error 2 {{cannot be specialized}}
102108
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
130136
SPECIALIZE_UTT(is_trivially_destructible); // expected-error 2 {{cannot be specialized}}
131137
SPECIALIZE_UTT(is_trivially_move_assignable); // expected-error 2 {{cannot be specialized}}
132138
SPECIALIZE_UTT(is_trivially_move_constructible); // expected-error 2 {{cannot be specialized}}
133-
SPECIALIZE_UTT(is_unbounded_array); // expected-error 2 {{cannot be specialized}}
134139
SPECIALIZE_UTT(is_union); // expected-error 2 {{cannot be specialized}}
135140
SPECIALIZE_UTT(is_unsigned); // expected-error 2 {{cannot be specialized}}
136141
SPECIALIZE_UTT(is_void); // expected-error 2 {{cannot be specialized}}
@@ -140,11 +145,12 @@ SPECIALIZE_UTT(rank); // expected-error 2 {{cannot
140145

141146
# if TEST_STD_VER <= 17
142147
SPECIALIZE_UTT(is_literal_type); // expected-error 2 {{cannot be specialized}}
143-
SPECIALIZE_UTT(result_of); // expected-error 2 {{cannot be specialized}}
144148
# endif
145149

146150
# if TEST_STD_VER >= 20
147-
SPECIALIZE_UTT(is_bounded_array); // expected-error 2 {{cannot be specialized}}
151+
SPECIALIZE_UTT(is_bounded_array); // expected-error 2 {{cannot be specialized}}
152+
SPECIALIZE_BTT(is_nothrow_convertible); // expected-error 2 {{cannot be specialized}}
153+
SPECIALIZE_UTT(is_unbounded_array); // expected-error 2 {{cannot be specialized}}
148154
# endif
149155

150156
# if TEST_STD_VER >= 23
@@ -171,6 +177,8 @@ struct std::conditional<true, S, S>; // expected-error {{cannot be specialized}}
171177
template <>
172178
struct std::enable_if<true, S>; // expected-error {{cannot be specialized}}
173179

180+
#if TEST_STD_VER >= 20
174181
template <>
175182
struct std::integral_constant<S, {}>; // expected-error {{cannot be specialized}}
176183
#endif
184+
#endif

0 commit comments

Comments
 (0)