[PATCH] D29138: [libcxx] [test] Fix Clang -Wdeprecated-declarations with MSVC's CRT.

Stephan T. Lavavej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 10:36:43 PST 2017


STL_MSFT created this revision.

[libcxx] [test] Fix Clang -Wdeprecated-declarations with MSVC's CRT.

libcxx's tests use various C Standard Library functions that have been
marked by MSVC's CRT as deprecated by Microsoft (not by ISO).

libcxx's usage is cromulent (just checking with decltype to see if the functions
are being dragged in by various headers as required by the Standard), so
defining _CRT_SECURE_NO_WARNINGS will silence the warnings in a targeted manner.
This needs to be defined before including any CRT headers.

Also, make this file prettier.


https://reviews.llvm.org/D29138

Files:
  test/support/msvc_stdlib_force_include.hpp


Index: test/support/msvc_stdlib_force_include.hpp
===================================================================
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -13,14 +13,17 @@
 // This header is force-included when running the libc++ tests against the
 // MSVC standard library.
 
+// Silence warnings about CRT machinery.
+#define _CRT_SECURE_NO_WARNINGS
+
 // Avoid assertion dialogs.
 #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
 
 #include <crtdbg.h>
 #include <stdlib.h>
 
 #if defined(_LIBCPP_VERSION)
-#error This header may not be used when targeting libc++
+    #error This header may not be used when targeting libc++
 #endif
 
 struct AssertionDialogAvoider {
@@ -35,27 +38,24 @@
 
 const AssertionDialogAvoider assertion_dialog_avoider{};
 
-
 // MSVC frontend only configurations
 #if !defined(__clang__)
-
-#define TEST_STD_VER 17
-
-// Simulate feature-test macros.
-#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
-#define _MSVC_HAS_FEATURE_cxx_exceptions    1
-#define _MSVC_HAS_FEATURE_cxx_rtti          1
-#define _MSVC_HAS_FEATURE_address_sanitizer 0
-#define _MSVC_HAS_FEATURE_memory_sanitizer  0
-#define _MSVC_HAS_FEATURE_thread_sanitizer  0
-
-// Silence compiler warnings.
-#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
-#pragma warning(disable: 4521) // multiple copy constructors specified
-#pragma warning(disable: 4702) // unreachable code
-#pragma warning(disable: 6294) // Ill-defined for-loop:  initial condition does not satisfy test.  Loop body not executed.
-#pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
-
+    #define TEST_STD_VER 17
+
+    // Simulate feature-test macros.
+    #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
+    #define _MSVC_HAS_FEATURE_cxx_exceptions    1
+    #define _MSVC_HAS_FEATURE_cxx_rtti          1
+    #define _MSVC_HAS_FEATURE_address_sanitizer 0
+    #define _MSVC_HAS_FEATURE_memory_sanitizer  0
+    #define _MSVC_HAS_FEATURE_thread_sanitizer  0
+
+    // Silence compiler warnings.
+    #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
+    #pragma warning(disable: 4521) // multiple copy constructors specified
+    #pragma warning(disable: 4702) // unreachable code
+    #pragma warning(disable: 6294) // Ill-defined for-loop:  initial condition does not satisfy test.  Loop body not executed.
+    #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
 #endif // !defined(__clang__)
 
 // MSVC doesn't have __int128_t.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29138.85780.patch
Type: text/x-patch
Size: 2663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170125/01457d56/attachment.bin>


More information about the cfe-commits mailing list