Home | History | Annotate | Download | only in support
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
     11 #define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
     12 
     13 // This header is force-included when running the libc++ tests against the
     14 // MSVC standard library.
     15 
     16 #ifndef _LIBCXX_IN_DEVCRT
     17     // Silence warnings about CRT machinery.
     18     #define _CRT_SECURE_NO_WARNINGS
     19 
     20     // Avoid assertion dialogs.
     21     #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
     22 #endif // _LIBCXX_IN_DEVCRT
     23 
     24 #include <crtdbg.h>
     25 #include <stdlib.h>
     26 
     27 #if defined(_LIBCPP_VERSION)
     28     #error This header may not be used when targeting libc++
     29 #endif
     30 
     31 #ifndef _LIBCXX_IN_DEVCRT
     32 struct AssertionDialogAvoider {
     33     AssertionDialogAvoider() {
     34         _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
     35         _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
     36 
     37         _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
     38         _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
     39     }
     40 };
     41 
     42 const AssertionDialogAvoider assertion_dialog_avoider{};
     43 #endif // _LIBCXX_IN_DEVCRT
     44 
     45 // MSVC frontend only configurations
     46 #if !defined(__clang__)
     47     // Simulate feature-test macros.
     48     #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
     49     #define _MSVC_HAS_FEATURE_cxx_exceptions    1
     50     #define _MSVC_HAS_FEATURE_cxx_rtti          1
     51     #define _MSVC_HAS_FEATURE_address_sanitizer 0
     52     #define _MSVC_HAS_FEATURE_memory_sanitizer  0
     53     #define _MSVC_HAS_FEATURE_thread_sanitizer  0
     54 
     55     // Silence compiler warnings.
     56     #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
     57     #pragma warning(disable: 4521) // multiple copy constructors specified
     58     #pragma warning(disable: 4702) // unreachable code
     59     #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
     60 #endif // !defined(__clang__)
     61 
     62 // MSVC doesn't have __int128_t.
     63 #define _LIBCPP_HAS_NO_INT128
     64 
     65 // MSVC has quick_exit() and at_quick_exit().
     66 #define _LIBCPP_HAS_QUICK_EXIT
     67 
     68 #ifndef _LIBCXX_IN_DEVCRT
     69     // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
     70     #define _ENABLE_ATOMIC_ALIGNMENT_FIX
     71 
     72     // Enable features that /std:c++latest removes by default.
     73     #define _HAS_AUTO_PTR_ETC               1
     74     #define _HAS_FUNCTION_ALLOCATOR_SUPPORT 1
     75     #define _HAS_OLD_IOSTREAMS_MEMBERS      1
     76     #define _HAS_UNEXPECTED                 1
     77 
     78     // Silence warnings about raw pointers and other unchecked iterators.
     79     #define _SCL_SECURE_NO_WARNINGS
     80 
     81     // Silence warnings about features that are deprecated in C++17.
     82     #define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
     83 #endif // _LIBCXX_IN_DEVCRT
     84 
     85 #include <ciso646>
     86 
     87 #if _HAS_CXX17
     88     #define TEST_STD_VER 17
     89 #else // _HAS_CXX17
     90     #define TEST_STD_VER 14
     91 #endif // _HAS_CXX17
     92 
     93 #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP
     94