Skip to content

Commit a972703

Browse files
committed
P1152R4: Fix deprecation warnings in libc++ testsuite and in uses of is_invocable that would internally conjure up a deprecated function type.
Summary: The implementation of P1152R4 in Clang has resulted in some deprecation warnings appearing in the libc++ and libc++abi test suite. Fix or suppress these warnings. Reviewers: mclow.lists, EricWF Subscribers: christof, ldionne, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68879 llvm-svn: 375307
1 parent 974c8b7 commit a972703

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

libcxx/include/__config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,20 @@ typedef unsigned int char32_t;
963963
# define _LIBCPP_DEPRECATED_IN_CXX17
964964
#endif
965965

966+
// Macros to enter and leave a state where deprecation warnings are suppressed.
967+
#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
968+
(defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
969+
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
970+
_Pragma("GCC diagnostic push") \
971+
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
972+
# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
973+
_Pragma("GCC diagnostic pop")
974+
#endif
975+
#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
976+
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
977+
# define _LIBCPP_SUPPRESS_DEPRECATED_POP
978+
#endif
979+
966980
#if _LIBCPP_STD_VER <= 11
967981
# define _LIBCPP_EXPLICIT_AFTER_CXX11
968982
#else

libcxx/include/type_traits

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
11191119
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
11201120
#endif
11211121

1122+
// Suppress deprecation notice for volatile-qualified return type resulting
1123+
// from volatile-qualified types _Tp.
1124+
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
11221125
template <class _Tp> _Tp&& __declval(int);
11231126
template <class _Tp> _Tp __declval(long);
1127+
_LIBCPP_SUPPRESS_DEPRECATED_POP
11241128

11251129
template <class _Tp>
11261130
decltype(_VSTD::__declval<_Tp>(0))

libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ void test_result_of_imp()
5555
#endif
5656
}
5757

58+
// Do not warn on deprecated uses of 'volatile' below.
59+
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
60+
5861
int main(int, char**)
5962
{
6063
{
@@ -171,3 +174,5 @@ int main(int, char**)
171174

172175
return 0;
173176
}
177+
178+
_LIBCPP_SUPPRESS_DEPRECATED_POP

libcxxabi/test/unwind_06.pass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ volatile int counter;
2424
double try1(bool v) {
2525
double a = get(0);
2626
double b = get(1);
27-
for (counter = 100; counter; --counter)
27+
for (counter = 100; counter; counter = counter - 1)
2828
a += get(1) + b;
2929
if (v) throw 10;
3030
return get(0)+a+b;
@@ -34,7 +34,7 @@ double try2(bool v) {
3434
double a = get(0);
3535
double b = get(1);
3636
double c = get(2);
37-
for (counter = 100; counter; --counter)
37+
for (counter = 100; counter; counter = counter - 1)
3838
a += get(1) + b + c;
3939
if (v) throw 10;
4040
return get(0)+a+b+c;
@@ -45,7 +45,7 @@ double try3(bool v) {
4545
double b = get(1);
4646
double c = get(2);
4747
double d = get(3);
48-
for (counter = 100; counter; --counter)
48+
for (counter = 100; counter; counter = counter - 1)
4949
a += get(1) + b + c + d;
5050
if (v) throw 10;
5151
return get(0)+a+b+c+d;
@@ -57,7 +57,7 @@ double try4(bool v) {
5757
double c = get(0);
5858
double d = get(0);
5959
double e = get(0);
60-
for (counter = 100; counter; --counter)
60+
for (counter = 100; counter; counter = counter - 1)
6161
a += get(1) + b+c+d+e;
6262
if (v) throw 10;
6363
return get(0)+a+b+c+d+e;
@@ -70,7 +70,7 @@ double try5(bool v) {
7070
double d = get(0);
7171
double e = get(0);
7272
double f = get(0);
73-
for (counter = 100; counter; --counter)
73+
for (counter = 100; counter; counter = counter - 1)
7474
a += get(1) + b+c+d+e+f;
7575
if (v) throw 10;
7676
return get(0)+a+b+c+d+e+f;
@@ -84,7 +84,7 @@ double try6(bool v) {
8484
double e = get(0);
8585
double f = get(0);
8686
double g = get(0);
87-
for (counter = 100; counter; --counter)
87+
for (counter = 100; counter; counter = counter - 1)
8888
a += get(1) + b+c+d+e+f+g;
8989
if (v) throw 10;
9090
return get(0)+a+b+c+d+e+f+g;
@@ -99,7 +99,7 @@ double try7(bool v) {
9999
double f = get(0);
100100
double g = get(0);
101101
double h = get(0);
102-
for (counter = 100; counter; --counter)
102+
for (counter = 100; counter; counter = counter - 1)
103103
a += get(1) + b+c+d+e+f+g+h;
104104
if (v) throw 10;
105105
return get(0)+a+b+c+d+e+f+g+h;
@@ -115,7 +115,7 @@ double try8(bool v) {
115115
double g = get(0);
116116
double h = get(0);
117117
double i = get(0);
118-
for (counter = 100; counter; --counter)
118+
for (counter = 100; counter; counter = counter - 1)
119119
a += get(1) + b+c+d+e+f+g+h+i;
120120
if (v) throw 10;
121121
return get(0)+a+b+c+d+e+f+g+h+i;

0 commit comments

Comments
 (0)