From a9727033fb5fa229b520e0e0d973f68780bc5348 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 19 Oct 2019 00:06:00 +0000 Subject: [PATCH] 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 --- libcxx/include/__config | 14 ++++++++++++++ libcxx/include/type_traits | 4 ++++ .../meta.trans.other/result_of11.pass.cpp | 5 +++++ libcxxabi/test/unwind_06.pass.cpp | 16 ++++++++-------- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index ee7351e9313d..1ae2fdc7b810 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -963,6 +963,20 @@ typedef unsigned int char32_t; # define _LIBCPP_DEPRECATED_IN_CXX17 #endif +// Macros to enter and leave a state where deprecation warnings are suppressed. +#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \ + (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC)) +# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") +# define _LIBCPP_SUPPRESS_DEPRECATED_POP \ + _Pragma("GCC diagnostic pop") +#endif +#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) +# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH +# define _LIBCPP_SUPPRESS_DEPRECATED_POP +#endif + #if _LIBCPP_STD_VER <= 11 # define _LIBCPP_EXPLICIT_AFTER_CXX11 #else diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 77dcc2321d99..77b57a41e418 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1119,8 +1119,12 @@ template struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; #endif +// Suppress deprecation notice for volatile-qualified return type resulting +// from volatile-qualified types _Tp. +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template _Tp&& __declval(int); template _Tp __declval(long); +_LIBCPP_SUPPRESS_DEPRECATED_POP template decltype(_VSTD::__declval<_Tp>(0)) diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp index 2128590047d6..595989c4f3fa 100644 --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -55,6 +55,9 @@ void test_result_of_imp() #endif } +// Do not warn on deprecated uses of 'volatile' below. +_LIBCPP_SUPPRESS_DEPRECATED_PUSH + int main(int, char**) { { @@ -171,3 +174,5 @@ int main(int, char**) return 0; } + +_LIBCPP_SUPPRESS_DEPRECATED_POP diff --git a/libcxxabi/test/unwind_06.pass.cpp b/libcxxabi/test/unwind_06.pass.cpp index e4c04e837451..7d67f52f8e02 100644 --- a/libcxxabi/test/unwind_06.pass.cpp +++ b/libcxxabi/test/unwind_06.pass.cpp @@ -24,7 +24,7 @@ volatile int counter; double try1(bool v) { double a = get(0); double b = get(1); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b; if (v) throw 10; return get(0)+a+b; @@ -34,7 +34,7 @@ double try2(bool v) { double a = get(0); double b = get(1); double c = get(2); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b + c; if (v) throw 10; return get(0)+a+b+c; @@ -45,7 +45,7 @@ double try3(bool v) { double b = get(1); double c = get(2); double d = get(3); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b + c + d; if (v) throw 10; return get(0)+a+b+c+d; @@ -57,7 +57,7 @@ double try4(bool v) { double c = get(0); double d = get(0); double e = get(0); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b+c+d+e; if (v) throw 10; return get(0)+a+b+c+d+e; @@ -70,7 +70,7 @@ double try5(bool v) { double d = get(0); double e = get(0); double f = get(0); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b+c+d+e+f; if (v) throw 10; return get(0)+a+b+c+d+e+f; @@ -84,7 +84,7 @@ double try6(bool v) { double e = get(0); double f = get(0); double g = get(0); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b+c+d+e+f+g; if (v) throw 10; return get(0)+a+b+c+d+e+f+g; @@ -99,7 +99,7 @@ double try7(bool v) { double f = get(0); double g = get(0); double h = get(0); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b+c+d+e+f+g+h; if (v) throw 10; return get(0)+a+b+c+d+e+f+g+h; @@ -115,7 +115,7 @@ double try8(bool v) { double g = get(0); double h = get(0); double i = get(0); - for (counter = 100; counter; --counter) + for (counter = 100; counter; counter = counter - 1) a += get(1) + b+c+d+e+f+g+h+i; if (v) throw 10; return get(0)+a+b+c+d+e+f+g+h+i;