aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-16 19:47:31 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-16 19:47:31 +0000
commit7582e3938bb9fb3e4664efdfb2313df29f27b70b (patch)
tree65bec6df3984fb0b437488fd86eb1359e9c84af4
parent733153a0fb52facba02c550ec849f0c734dfa412 (diff)
downloadsrc-7582e3938bb9fb3e4664efdfb2313df29f27b70b.tar.gz
src-7582e3938bb9fb3e4664efdfb2313df29f27b70b.zip
Vendor import of libc++ trunk r303197:vendor/libc++/libc++-trunk-r303197
Notes
Notes: svn path=/vendor/libc++/dist/; revision=318374 svn path=/vendor/libc++/libc++-trunk-r303197/; revision=318375; tag=vendor/libc++/libc++-trunk-r303197
-rw-r--r--appveyor-reqs-install.cmd (renamed from install-appveyor-reqs.cmd)12
-rw-r--r--appveyor.yml22
-rw-r--r--docs/CMakeLists.txt4
-rw-r--r--docs/TestingLibcxx.rst2
-rw-r--r--include/__bsd_locale_fallbacks.h31
-rw-r--r--include/__config12
-rw-r--r--include/__locale19
-rw-r--r--include/__mutex_base1
-rw-r--r--include/__threading_support1
-rw-r--r--include/__undef_min_max4
-rw-r--r--include/algorithm127
-rw-r--r--include/ctype.h9
-rw-r--r--include/experimental/numeric13
-rw-r--r--include/ext/hash_map2
-rw-r--r--include/ext/hash_set2
-rw-r--r--include/limits4
-rw-r--r--include/locale3
-rw-r--r--include/memory10
-rw-r--r--include/numeric11
-rw-r--r--include/stdio.h5
-rw-r--r--include/stdlib.h4
-rw-r--r--include/string_view8
-rw-r--r--include/support/win32/limits_msvc_win32.h (renamed from include/support/win32/limits_win32.h)27
-rw-r--r--include/support/win32/locale_mgmt_win32.h33
-rw-r--r--include/support/win32/locale_win32.h32
-rw-r--r--include/support/win32/support.h177
-rw-r--r--include/variant25
-rw-r--r--include/wchar.h9
-rw-r--r--src/include/atomic_support.h2
-rw-r--r--src/locale.cpp46
-rw-r--r--src/string.cpp5
-rw-r--r--src/support/runtime/exception_pointer_msvc.ipp1
-rw-r--r--src/support/win32/locale_win32.cpp26
-rw-r--r--src/thread.cpp2
-rw-r--r--test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp (renamed from test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp)2
-rw-r--r--test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp (renamed from test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp)2
-rw-r--r--test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp (renamed from test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp)0
-rw-r--r--test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp (renamed from test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp)1
-rw-r--r--test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp (renamed from test/std/utilities/function.objects/refwrap/binary.pass.cpp)0
-rw-r--r--test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp (renamed from test/std/utilities/function.objects/refwrap/unary.pass.cpp)0
-rw-r--r--test/libcxx/utilities/template.bitset/includes.pass.cpp32
-rw-r--r--test/libcxx/utilities/tuple/tuple.tuple/empty_member.pass.cpp (renamed from test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp)0
-rw-r--r--test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp6
-rw-r--r--test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp3
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp2
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp3
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp3
-rw-r--r--test/std/language.support/support.types/byteops/and.assign.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/and.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp21
-rw-r--r--test/std/language.support/support.types/byteops/lshift.assign.pass.cpp7
-rw-r--r--test/std/language.support/support.types/byteops/lshift.fail.cpp5
-rw-r--r--test/std/language.support/support.types/byteops/lshift.pass.cpp7
-rw-r--r--test/std/language.support/support.types/byteops/not.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/or.assign.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/or.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/rshift.assign.pass.cpp7
-rw-r--r--test/std/language.support/support.types/byteops/rshift.fail.cpp5
-rw-r--r--test/std/language.support/support.types/byteops/rshift.pass.cpp7
-rw-r--r--test/std/language.support/support.types/byteops/to_integer.fail.cpp5
-rw-r--r--test/std/language.support/support.types/byteops/to_integer.pass.cpp7
-rw-r--r--test/std/language.support/support.types/byteops/xor.assign.pass.cpp9
-rw-r--r--test/std/language.support/support.types/byteops/xor.pass.cpp9
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp590
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp686
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp556
-rw-r--r--test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp664
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp39
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp65
-rw-r--r--test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp65
-rw-r--r--test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp45
-rw-r--r--test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp49
-rw-r--r--test/std/re/re.traits/lookup_classname.pass.cpp68
-rw-r--r--test/std/strings/basic.string/string.cons/T_size_size.pass.cpp18
-rw-r--r--test/std/strings/string.view/string.view.modifiers/clear.pass.cpp67
-rw-r--r--test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp22
-rw-r--r--test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp8
-rw-r--r--test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp3
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp4
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp10
-rw-r--r--test/std/utilities/meta/meta.rel/is_convertible.pass.cpp4
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp12
-rw-r--r--test/std/utilities/template.bitset/includes.pass.cpp35
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp4
-rw-r--r--test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp4
-rw-r--r--test/std/utilities/variant/variant.visit/visit.pass.cpp10
-rw-r--r--test/support/archetypes.hpp9
-rw-r--r--test/support/archetypes.ipp4
-rw-r--r--test/support/filesystem_dynamic_test_helper.py2
-rw-r--r--test/support/filesystem_test_helper.hpp4
-rw-r--r--test/support/msvc_stdlib_force_include.hpp30
-rw-r--r--test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp41
-rw-r--r--test/support/test_macros.h8
-rw-r--r--test/support/test_workarounds.h7
-rw-r--r--utils/libcxx/test/config.py25
-rw-r--r--utils/libcxx/test/executor.py31
-rw-r--r--utils/libcxx/test/format.py2
-rw-r--r--www/cxx1z_status.html10
106 files changed, 1931 insertions, 2165 deletions
diff --git a/install-appveyor-reqs.cmd b/appveyor-reqs-install.cmd
index ebd72ca0a2da..3a2087af51fe 100644
--- a/install-appveyor-reqs.cmd
+++ b/appveyor-reqs-install.cmd
@@ -1,11 +1,12 @@
@echo on
+
if NOT EXIST C:\projects\deps (
mkdir C:\projects\deps
)
cd C:\projects\deps
::###########################################################################
-:: Setup the path to Clang-cl
+:: Setup Compiler
::###########################################################################
if NOT EXIST llvm-installer.exe (
appveyor DownloadFile http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r301646-win32.exe -FileName llvm-installer.exe
@@ -13,8 +14,13 @@ if NOT EXIST llvm-installer.exe (
if "%CLANG_VERSION%"=="ToT" (
START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"
)
-@set PATH="C:\Program Files\LLVM\bin";%PATH%
-clang-cl -v
+if DEFINED CLANG_VERSION @set PATH="C:\Program Files\LLVM\bin";%PATH%
+if DEFINED CLANG_VERSION clang-cl -v
+
+if DEFINED MINGW_PATH rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe"
+if DEFINED MINGW_PATH @set "PATH=%PATH:C:\Program Files (x86)\Git\bin=%"
+if DEFINED MINGW_PATH @set "PATH=%PATH%;%MINGW_PATH%"
+if DEFINED MINGW_PATH g++ -v
::###########################################################################
:: Install a recent CMake
diff --git a/appveyor.yml b/appveyor.yml
index 1d9e88a87b15..be69a555d778 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,24 +11,35 @@ configuration:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+ CMAKE_OPTIONS: -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe
CLANG_VERSION: ToT
MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
MSVC_SETUP_ARG: x86
+ GENERATOR: Ninja
+ MAKE_PROGRAM: ninja
APPVEYOR_SAVE_CACHE_ON_ERROR: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ CMAKE_OPTIONS: -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe
CLANG_VERSION: 4
MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
MSVC_SETUP_ARG: x86_amd64
+ GENERATOR: Ninja
+ MAKE_PROGRAM: ninja
+ APPVEYOR_SAVE_CACHE_ON_ERROR: true
+ - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ MINGW_PATH: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin
+ GENERATOR: MinGW Makefiles
+ MAKE_PROGRAM: mingw32-make
APPVEYOR_SAVE_CACHE_ON_ERROR: true
install:
############################################################################
# All external dependencies are installed in C:\projects\deps
############################################################################
- - call "%APPVEYOR_BUILD_FOLDER%\\install-appveyor-reqs.cmd"
+ - call "%APPVEYOR_BUILD_FOLDER%\\appveyor-reqs-install.cmd"
before_build:
- - call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%
+ - if DEFINED MSVC_SETUP_PATH call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%
- cd %APPVEYOR_BUILD_FOLDER%
build_script:
@@ -39,8 +50,7 @@ build_script:
#############################################################################
# Configuration Step
#############################################################################
- - cmake -G Ninja %extra_cmake_flags%
- -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe
+ - cmake -G "%GENERATOR%" %CMAKE_OPTIONS%
"-DCMAKE_BUILD_TYPE=%configuration%"
"-DLLVM_PATH=C:\projects\deps\llvm" -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
-DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported"
@@ -49,10 +59,10 @@ build_script:
#############################################################################
# Build Step
#############################################################################
- - ninja
+ - "%MAKE_PROGRAM%"
test_script:
- - ninja check-cxx
+ - "%MAKE_PROGRAM% check-cxx"
on_failure:
- appveyor PushArtifact CMakeFiles/CMakeOutput.log
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index f63ee00a5a02..d679761a5adb 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -1,9 +1,9 @@
if (LLVM_ENABLE_SPHINX)
+ include(AddSphinxTarget)
if (SPHINX_FOUND)
- include(AddSphinxTarget)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html libcxx)
endif()
endif()
-endif() \ No newline at end of file
+endif()
diff --git a/docs/TestingLibcxx.rst b/docs/TestingLibcxx.rst
index e4292764c4d0..5c48ebe61ddf 100644
--- a/docs/TestingLibcxx.rst
+++ b/docs/TestingLibcxx.rst
@@ -119,7 +119,7 @@ configuration. Passing the option on the command line will override the default.
.. option:: libcxx_site_config=<path/to/lit.site.cfg>
Specify the site configuration to use when running the tests. This option
- overrides the enviroment variable LIBCXX_SITE_CONFIG.
+ overrides the environment variable LIBCXX_SITE_CONFIG.
.. option:: cxx_headers=<path/to/headers>
diff --git a/include/__bsd_locale_fallbacks.h b/include/__bsd_locale_fallbacks.h
index cbc8ad226fd2..3425ce659b7e 100644
--- a/include/__bsd_locale_fallbacks.h
+++ b/include/__bsd_locale_fallbacks.h
@@ -19,27 +19,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-typedef _VSTD::remove_pointer<locale_t>::type __use_locale_struct;
-typedef _VSTD::unique_ptr<__use_locale_struct, decltype(&uselocale)> __locale_raii;
-
inline _LIBCPP_ALWAYS_INLINE
decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return MB_CUR_MAX;
}
inline _LIBCPP_ALWAYS_INLINE
wint_t __libcpp_btowc_l(int __c, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return btowc(__c);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_wctob_l(wint_t __c, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return wctob(__c);
}
@@ -47,14 +44,14 @@ inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
size_t __len, mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
}
inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return wcrtomb(__s, __wc, __ps);
}
@@ -62,7 +59,7 @@ inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms,
size_t __len, mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
}
@@ -70,28 +67,28 @@ inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return mbrtowc(__pwc, __s, __n, __ps);
}
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return mbtowc(__pwc, __pmb, __max);
}
inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return mbrlen(__s, __n, __ps);
}
inline _LIBCPP_ALWAYS_INLINE
lconv *__libcpp_localeconv_l(locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return localeconv();
}
@@ -99,7 +96,7 @@ inline _LIBCPP_ALWAYS_INLINE
size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
mbstate_t *__ps, locale_t __l)
{
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
return mbsrtowcs(__dest, __src, __len, __ps);
}
@@ -107,7 +104,7 @@ inline
int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
int __res = vsnprintf(__s, __n, __format, __va);
va_end(__va);
return __res;
@@ -117,7 +114,7 @@ inline
int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
int __res = vasprintf(__s, __format, __va);
va_end(__va);
return __res;
@@ -127,7 +124,7 @@ inline
int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
- __locale_raii __current( uselocale(__l), uselocale );
+ __libcpp_locale_guard __current(__l);
int __res = vsscanf(__s, __format, __va);
va_end(__va);
return __res;
diff --git a/include/__config b/include/__config
index 2a2907494b2b..4ad700e234c2 100644
--- a/include/__config
+++ b/include/__config
@@ -129,6 +129,12 @@
#define __has_keyword(__x) !(__is_identifier(__x))
+#ifdef __has_include
+#define __libcpp_has_include(__x) __has_include(__x)
+#else
+#define __libcpp_has_include(__x) 0
+#endif
+
#if defined(__clang__)
#define _LIBCPP_COMPILER_CLANG
# ifndef __apple_build_version__
@@ -968,7 +974,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \
(__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI)
# define _LIBCPP_NO_RTTI
-# elif defined(_LIBCPP_MSVC) && !defined(_CPPRTTI)
+# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI)
# define _LIBCPP_NO_RTTI
# endif
#endif
@@ -980,6 +986,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
// Thread API
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+ !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# if defined(__FreeBSD__) || \
defined(__Fuchsia__) || \
@@ -987,7 +994,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
defined(__linux__) || \
defined(__APPLE__) || \
defined(__CloudABI__) || \
- defined(__sun__)
+ defined(__sun__) || \
+ (defined(__MINGW32__) && __libcpp_has_include(<pthread.h>))
# define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_HAS_THREAD_API_WIN32
diff --git a/include/__locale b/include/__locale
index 4184e7e03489..cf3ba23b9092 100644
--- a/include/__locale
+++ b/include/__locale
@@ -49,6 +49,25 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS) || defined(_LIBCPP_MSVCRT)
+struct __libcpp_locale_guard {
+ _LIBCPP_INLINE_VISIBILITY
+ __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__libcpp_locale_guard() {
+ if (__old_loc_)
+ uselocale(__old_loc_);
+ }
+
+ locale_t __old_loc_;
+private:
+ __libcpp_locale_guard(__libcpp_locale_guard const&);
+ __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
+};
+#endif
+
+
class _LIBCPP_TYPE_VIS locale;
template <class _Facet>
diff --git a/include/__mutex_base b/include/__mutex_base
index a6d5e79c4c86..7f5e2ea2810e 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -15,6 +15,7 @@
#include <chrono>
#include <system_error>
#include <__threading_support>
+#include <__undef_min_max>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/include/__threading_support b/include/__threading_support
index 080ebd256b8f..385fff32b350 100644
--- a/include/__threading_support
+++ b/include/__threading_support
@@ -30,6 +30,7 @@
#include <Windows.h>
#include <process.h>
#include <fibersapi.h>
+#include <__undef_min_max>
#endif
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
diff --git a/include/__undef_min_max b/include/__undef_min_max
index f4ca091def45..71db3965e3cd 100644
--- a/include/__undef_min_max
+++ b/include/__undef_min_max
@@ -10,7 +10,7 @@
#ifdef min
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_MSVC)
+#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing min")
#else
@@ -22,7 +22,7 @@ _LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
#ifdef max
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_MSVC)
+#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing max")
#else
diff --git a/include/algorithm b/include/algorithm
index c3517a11bb0d..08ca23ff6168 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -644,8 +644,8 @@ template <class BidirectionalIterator, class Compare>
#if defined(__IBMCPP__)
#include "support/ibm/support.h"
#endif
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#include "support/win32/support.h"
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include <intrin.h>
#endif
#include <__undef_min_max>
@@ -783,51 +783,132 @@ struct __debug_less
// Precondition: __x != 0
inline _LIBCPP_INLINE_VISIBILITY
-unsigned
-__ctz(unsigned __x)
-{
+unsigned __ctz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned>(__builtin_ctz(__x));
+#else
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long where;
+ // Search from LSB to MSB for first set bit.
+ // Returns zero if no set bit is found.
+ if (_BitScanForward(&where, mask))
+ return where;
+ return 32;
+#endif
}
inline _LIBCPP_INLINE_VISIBILITY
-unsigned long
-__ctz(unsigned long __x)
-{
+unsigned long __ctz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned long>(__builtin_ctzl(__x));
+#else
+ static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
+ return __ctz(static_cast<unsigned>(__x));
+#endif
}
inline _LIBCPP_INLINE_VISIBILITY
-unsigned long long
-__ctz(unsigned long long __x)
-{
+unsigned long long __ctz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned long long>(__builtin_ctzll(__x));
+#else
+ unsigned long where;
+// Search from LSB to MSB for first set bit.
+// Returns zero if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ (defined(_M_AMD64) || defined(__x86_64__))
+ if (_BitScanForward64(&where, mask))
+ return static_cast<int>(where);
+#else
+ // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+ // Scan the Low Word.
+ if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
+ return where;
+ // Scan the High Word.
+ if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
+ return where + 32; // Create a bit offset from the LSB.
+#endif
+ return 64;
+#endif // _LIBCPP_COMPILER_MSVC
}
// Precondition: __x != 0
inline _LIBCPP_INLINE_VISIBILITY
-unsigned
-__clz(unsigned __x)
-{
+unsigned __clz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned>(__builtin_clz(__x));
+#else
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ static_assert(sizeof(unsigned long) == 4, "");
+ unsigned long where;
+ // Search from LSB to MSB for first set bit.
+ // Returns zero if no set bit is found.
+ if (_BitScanReverse(&where, mask))
+ return 31 - where;
+ return 32; // Undefined Behavior.
+#endif
}
inline _LIBCPP_INLINE_VISIBILITY
-unsigned long
-__clz(unsigned long __x)
-{
+unsigned long __clz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned long>(__builtin_clzl (__x));
+#else
+ static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+ return __clz(static_cast<unsigned>(__x));
+#endif
}
inline _LIBCPP_INLINE_VISIBILITY
-unsigned long long
-__clz(unsigned long long __x)
-{
+unsigned long long __clz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
return static_cast<unsigned long long>(__builtin_clzll(__x));
+#else
+ unsigned long where;
+// BitScanReverse scans from MSB to LSB for first set bit.
+// Returns 0 if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+ if (_BitScanReverse64(&where, mask))
+ return static_cast<int>(63 - where);
+#else
+ // Scan the high 32 bits.
+ if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
+ return 63 - (where + 32); // Create a bit offset from the MSB.
+ // Scan the low 32 bits.
+ if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
+ return 63 - where;
+#endif
+ return 64; // Undefined Behavior.
+#endif // _LIBCPP_COMPILER_MSVC
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+ return __builtin_popcount (__x);
+#else
+ static_assert(sizeof(unsigned) == 4, "");
+ return __popcnt(__x);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+ return __builtin_popcountl (__x);
+#else
+ static_assert(sizeof(unsigned long) == 4, "");
+ return __popcnt(__x);
+#endif
}
-inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {return __builtin_popcount (__x);}
-inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {return __builtin_popcountl (__x);}
-inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {return __builtin_popcountll(__x);}
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+ return __builtin_popcountll(__x);
+#else
+ static_assert(sizeof(unsigned long long) == 8, "");
+ return __popcnt64(__x);
+#endif
+}
// all_of
diff --git a/include/ctype.h b/include/ctype.h
index 22d6c49be9e1..e97ff3c48876 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -40,15 +40,6 @@ int toupper(int c);
#ifdef __cplusplus
-#if defined(_LIBCPP_MSVCRT)
-// We support including .h headers inside 'extern "C"' contexts, so switch
-// back to C++ linkage before including these C++ headers.
-extern "C++" {
- #include "support/win32/support.h"
- #include "support/win32/locale_win32.h"
-}
-#endif // _LIBCPP_MSVCRT
-
#undef isalnum
#undef isalpha
#undef isblank
diff --git a/include/experimental/numeric b/include/experimental/numeric
index d1209dbec15b..6488a68eca6c 100644
--- a/include/experimental/numeric
+++ b/include/experimental/numeric
@@ -66,11 +66,11 @@ struct __abs<_Result, _Source, false> {
template<class _Tp>
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp __gcd(_Tp __m, _Tp __n)
+_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
+inline _Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "" );
- return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
+ return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
}
@@ -84,8 +84,9 @@ gcd(_Tp __m, _Up __n)
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
using _Rp = common_type_t<_Tp,_Up>;
using _Wp = make_unsigned_t<_Rp>;
- return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
- static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
+ return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
+ static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+ static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
}
template<class _Tp, class _Up>
@@ -100,7 +101,7 @@ lcm(_Tp __m, _Up __n)
return 0;
using _Rp = common_type_t<_Tp,_Up>;
- _Rp __val1 = __abs<_Rp, _Tp>()(__m) / gcd(__m, __n);
+ _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
_Rp __val2 = __abs<_Rp, _Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
diff --git a/include/ext/hash_map b/include/ext/hash_map
index 66f2b11c0594..998e8f65994e 100644
--- a/include/ext/hash_map
+++ b/include/ext/hash_map
@@ -207,7 +207,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <ext/__hash>
#if __DEPRECATED
-#if defined(_LIBCPP_MSVC)
+#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
#else
# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
diff --git a/include/ext/hash_set b/include/ext/hash_set
index 916ed6910d7d..38f81ed3b5c8 100644
--- a/include/ext/hash_set
+++ b/include/ext/hash_set
@@ -199,7 +199,7 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <ext/__hash>
#if __DEPRECATED
-#if defined(_LIBCPP_MSVC)
+#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
#else
# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>
diff --git a/include/limits b/include/limits
index 609c4d4ed95a..4755c57cf903 100644
--- a/include/limits
+++ b/include/limits
@@ -111,8 +111,8 @@ template<> class numeric_limits<cv long double>;
#include <__undef_min_max>
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/limits_win32.h"
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include "support/win32/limits_msvc_win32.h"
#endif // _LIBCPP_MSVCRT
#if defined(__IBMCPP__)
diff --git a/include/locale b/include/locale
index ad1c1f0083ec..d29a2dc70a5b 100644
--- a/include/locale
+++ b/include/locale
@@ -233,9 +233,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#define __cloc_defined
#endif
-typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
-typedef _VSTD::unique_ptr<__locale_struct, decltype(&freelocale)> __locale_unique_ptr;
-
// __scan_keyword
// Scans [__b, __e) until a match is found in the basic_strings range
// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
diff --git a/include/memory b/include/memory
index 41ab01b46f7e..4201c92dd723 100644
--- a/include/memory
+++ b/include/memory
@@ -996,11 +996,11 @@ struct __rebind_pointer {
// allocator_traits
-namespace __has_pointer_type_imp
+struct __has_pointer_type_imp
{
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::pointer* = 0);
-}
+};
template <class _Tp>
struct __has_pointer_type
@@ -3924,7 +3924,10 @@ private:
template <class _Yp, class _OrigPtr>
_LIBCPP_INLINE_VISIBILITY
- void
+ typename enable_if<is_convertible<_OrigPtr*,
+ const enable_shared_from_this<_Yp>*
+ >::value,
+ void>::type
__enable_weak_this(const enable_shared_from_this<_Yp>* __e,
_OrigPtr* __ptr) _NOEXCEPT
{
@@ -3943,6 +3946,7 @@ private:
template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
};
+
template<class _Tp>
inline
_LIBCPP_CONSTEXPR
diff --git a/include/numeric b/include/numeric
index 8f25146938a4..9c98cdbe262e 100644
--- a/include/numeric
+++ b/include/numeric
@@ -222,11 +222,11 @@ struct __abs<_Result, _Source, false> {
template<class _Tp>
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
_Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "");
- return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
+ return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n);
}
@@ -240,8 +240,9 @@ gcd(_Tp __m, _Up __n)
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
using _Rp = common_type_t<_Tp,_Up>;
using _Wp = make_unsigned_t<_Rp>;
- return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
- static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
+ return static_cast<_Rp>(_VSTD::__gcd(
+ static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+ static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
}
template<class _Tp, class _Up>
@@ -256,7 +257,7 @@ lcm(_Tp __m, _Up __n)
return 0;
using _Rp = common_type_t<_Tp,_Up>;
- _Rp __val1 = __abs<_Rp, _Tp>()(__m) / gcd(__m, __n);
+ _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n);
_Rp __val2 = __abs<_Rp, _Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
diff --git a/include/stdio.h b/include/stdio.h
index 56fb2d83bb28..dc534970f9d8 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -111,8 +111,9 @@ void perror(const char* s);
// snprintf
#if defined(_LIBCPP_MSVCRT)
-extern "C++" {
-#include "support/win32/support.h"
+extern "C" {
+int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+int asprintf(char **sptr, const char *__restrict fmt, ...);
}
#endif
diff --git a/include/stdlib.h b/include/stdlib.h
index 12fd676a15f5..f11c5e76226e 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -97,10 +97,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
extern "C++" {
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
-
#undef abs
#undef div
#undef labs
diff --git a/include/string_view b/include/string_view
index 5c42b36ca565..e59f099f16e7 100644
--- a/include/string_view
+++ b/include/string_view
@@ -103,7 +103,6 @@ namespace std {
constexpr const_pointer data() const noexcept;
// 7.7, basic_string_view modifiers
- constexpr void clear() noexcept;
constexpr void remove_prefix(size_type n);
constexpr void remove_suffix(size_type n);
constexpr void swap(basic_string_view& s) noexcept;
@@ -293,13 +292,6 @@ public:
// [string.view.modifiers], modifiers:
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- void clear() _NOEXCEPT
- {
- __data = nullptr;
- __size = 0;
- }
-
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
void remove_prefix(size_type __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
diff --git a/include/support/win32/limits_win32.h b/include/support/win32/limits_msvc_win32.h
index 406cd3025bf8..1ab2e0b6dc1b 100644
--- a/include/support/win32/limits_win32.h
+++ b/include/support/win32/limits_msvc_win32.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===--------------------- support/win32/limits_win32.h -------------------===//
+//===------------------ support/win32/limits_msvc_win32.h -----------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,17 +8,21 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
+#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
#if !defined(_LIBCPP_MSVCRT)
#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
-#else
+#endif
+#if defined(__clang__)
+#error "This header should only be included when using Microsofts C1XX frontend"
+#endif
#include <limits.h> // CHAR_BIT
#include <float.h> // limit constants
+#include <math.h> // HUGE_VAL
+#include <ymath.h> // internal MSVC header providing the needed functionality
-#if ! defined(__clang__)
#define __CHAR_BIT__ CHAR_BIT
#define __FLT_MANT_DIG__ FLT_MANT_DIG
@@ -61,19 +65,8 @@
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
// __builtin replacements/workarounds
-#include <math.h> // HUGE_VAL
-#include <ymath.h> // internal MSVC header providing the needed functionality
-#define __builtin_huge_val() HUGE_VAL
-#define __builtin_huge_valf() _FInf._Float
#define __builtin_huge_vall() _LInf._Long_double
-#define __builtin_nan(__dummy) _Nan._Double
-#define __builtin_nanf(__dummy) _FNan._Float
#define __builtin_nanl(__dummmy) _LNan._Long_double
-#define __builtin_nans(__dummy) _Snan._Double
-#define __builtin_nansf(__dummy) _FSnan._Float
#define __builtin_nansl(__dummy) _LSnan._Long_double
-#endif // ! defined(__clang__)
-
-#endif // _LIBCPP_MSVCRT
-#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
+#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
diff --git a/include/support/win32/locale_mgmt_win32.h b/include/support/win32/locale_mgmt_win32.h
deleted file mode 100644
index b3316d62596f..000000000000
--- a/include/support/win32/locale_mgmt_win32.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-//===----------------- support/win32/locale_mgmt_win32.h ------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
-
-#include <xlocinfo.h> // _locale_t
-#define locale_t _locale_t
-#define LC_COLLATE_MASK _M_COLLATE
-#define LC_CTYPE_MASK _M_CTYPE
-#define LC_MONETARY_MASK _M_MONETARY
-#define LC_NUMERIC_MASK _M_NUMERIC
-#define LC_TIME_MASK _M_TIME
-#define LC_MESSAGES_MASK _M_MESSAGES
-#define LC_ALL_MASK ( LC_COLLATE_MASK \
- | LC_CTYPE_MASK \
- | LC_MESSAGES_MASK \
- | LC_MONETARY_MASK \
- | LC_NUMERIC_MASK \
- | LC_TIME_MASK )
-#define freelocale _free_locale
-// FIXME: base currently unused. Needs manual work to construct the new locale
-locale_t newlocale( int mask, const char * locale, locale_t base );
-locale_t uselocale( locale_t newloc );
-
-#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H
diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h
index bc717d97990a..7a6c44ca9003 100644
--- a/include/support/win32/locale_win32.h
+++ b/include/support/win32/locale_win32.h
@@ -12,9 +12,30 @@
#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#include <__config>
-#include "support/win32/support.h"
-#include "support/win32/locale_mgmt_win32.h"
#include <stdio.h>
+#include <xlocinfo.h> // _locale_t
+
+#define LC_COLLATE_MASK _M_COLLATE
+#define LC_CTYPE_MASK _M_CTYPE
+#define LC_MONETARY_MASK _M_MONETARY
+#define LC_NUMERIC_MASK _M_NUMERIC
+#define LC_TIME_MASK _M_TIME
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_ALL_MASK ( LC_COLLATE_MASK \
+ | LC_CTYPE_MASK \
+ | LC_MESSAGES_MASK \
+ | LC_MONETARY_MASK \
+ | LC_NUMERIC_MASK \
+ | LC_TIME_MASK )
+
+#define locale_t _locale_t
+
+// Locale management functions
+#define freelocale _free_locale
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t base );
+locale_t uselocale( locale_t newloc );
+
lconv *localeconv_l( locale_t loc );
size_t mbrlen_l( const char *__restrict s, size_t n,
@@ -88,7 +109,6 @@ _LIBCPP_FUNC_VIS int snprintf_l(char *ret, size_t n, locale_t loc, const char *f
_LIBCPP_FUNC_VIS int asprintf_l( char **ret, locale_t loc, const char *format, ... );
_LIBCPP_FUNC_VIS int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
-
// not-so-pressing FIXME: use locale to determine blank characters
inline int isblank_l( int c, locale_t /*loc*/ )
{
@@ -99,10 +119,4 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ )
return ( c == L' ' || c == L'\t' );
}
-#if defined(_LIBCPP_MSVCRT)
-inline int isblank( int c, locale_t /*loc*/ )
-{ return ( c == ' ' || c == '\t' ); }
-inline int iswblank( wint_t c, locale_t /*loc*/ )
-{ return ( c == L' ' || c == L'\t' ); }
-#endif // _LIBCPP_MSVCRT
#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
diff --git a/include/support/win32/support.h b/include/support/win32/support.h
deleted file mode 100644
index e48b08ddad03..000000000000
--- a/include/support/win32/support.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// -*- C++ -*-
-//===----------------------- support/win32/support.h ----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-
-// Functions and constants used in libc++ that
-// are missing from the Windows C library.
-
-#include <wchar.h> // mbstate_t
-#include <cstdarg> // va_ macros
-// "builtins" not implemented here for Clang or GCC as they provide
-// implementations. Assuming required for elsewhere else, certainly MSVC.
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include <intrin.h>
-#endif
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-// The mingw headers already define these as static.
-#ifndef __MINGW32__
-extern "C" {
-
-int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
-int asprintf(char **sptr, const char *__restrict fmt, ...);
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
- size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
- size_t nwc, size_t len, mbstate_t *__restrict ps);
-}
-#endif // __MINGW32__
-
-#if defined(_LIBCPP_COMPILER_MSVC)
-
-// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
-// etc. These assumptions are expected to be true for Win32/Win64 which this
-// file supports.
-static_assert(sizeof(unsigned long long) == 8, "");
-static_assert(sizeof(unsigned long) == 4, "");
-static_assert(sizeof(unsigned int) == 4, "");
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
-{
- // Binary: 0101...
- static const unsigned int m1 = 0x55555555;
- // Binary: 00110011..
- static const unsigned int m2 = 0x33333333;
- // Binary: 4 zeros, 4 ones ...
- static const unsigned int m4 = 0x0f0f0f0f;
- // The sum of 256 to the power of 0,1,2,3...
- static const unsigned int h01 = 0x01010101;
- // Put count of each 2 bits into those 2 bits.
- x -= (x >> 1) & m1;
- // Put count of each 4 bits into those 4 bits.
- x = (x & m2) + ((x >> 2) & m2);
- // Put count of each 8 bits into those 8 bits.
- x = (x + (x >> 4)) & m4;
- // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24).
- return (x * h01) >> 24;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcountl(unsigned long x)
-{
- return __builtin_popcount(static_cast<int>(x));
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x)
-{
- // Binary: 0101...
- static const unsigned long long m1 = 0x5555555555555555;
- // Binary: 00110011..
- static const unsigned long long m2 = 0x3333333333333333;
- // Binary: 4 zeros, 4 ones ...
- static const unsigned long long m4 = 0x0f0f0f0f0f0f0f0f;
- // The sum of 256 to the power of 0,1,2,3...
- static const unsigned long long h01 = 0x0101010101010101;
- // Put count of each 2 bits into those 2 bits.
- x -= (x >> 1) & m1;
- // Put count of each 4 bits into those 4 bits.
- x = (x & m2) + ((x >> 2) & m2);
- // Put count of each 8 bits into those 8 bits.
- x = (x + (x >> 4)) & m4;
- // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
- return static_cast<int>((x * h01) >> 56);
-}
-
-// Returns the number of trailing 0-bits in x, starting at the least significant
-// bit position. If x is 0, the result is undefined.
-_LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
-{
- unsigned long where;
-// Search from LSB to MSB for first set bit.
-// Returns zero if no set bit is found.
-#if defined(_LIBCPP_HAS_BITSCAN64)
- (defined(_M_AMD64) || defined(__x86_64__))
- if (_BitScanForward64(&where, mask))
- return static_cast<int>(where);
-#else
- // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
- // Scan the Low Word.
- if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
- return static_cast<int>(where);
- // Scan the High Word.
- if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
- return static_cast<int>(where + 32); // Create a bit offset from the LSB.
-#endif
- return 64;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_ctzl(unsigned long mask)
-{
- unsigned long where;
- // Search from LSB to MSB for first set bit.
- // Returns zero if no set bit is found.
- if (_BitScanForward(&where, mask))
- return static_cast<int>(where);
- return 32;
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_ctz(unsigned int mask)
-{
- // Win32 and Win64 expectations.
- static_assert(sizeof(mask) == 4, "");
- static_assert(sizeof(unsigned long) == 4, "");
- return __builtin_ctzl(static_cast<unsigned long>(mask));
-}
-
-// Returns the number of leading 0-bits in x, starting at the most significant
-// bit position. If x is 0, the result is undefined.
-_LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
-{
- unsigned long where;
-// BitScanReverse scans from MSB to LSB for first set bit.
-// Returns 0 if no set bit is found.
-#if defined(_LIBCPP_HAS_BITSCAN64)
- if (_BitScanReverse64(&where, mask))
- return static_cast<int>(63 - where);
-#else
- // Scan the high 32 bits.
- if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
- return static_cast<int>(63 -
- (where + 32)); // Create a bit offset from the MSB.
- // Scan the low 32 bits.
- if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
- return static_cast<int>(63 - where);
-#endif
- return 64; // Undefined Behavior.
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_clzl(unsigned long mask)
-{
- unsigned long where;
- // Search from LSB to MSB for first set bit.
- // Returns zero if no set bit is found.
- if (_BitScanReverse(&where, mask))
- return static_cast<int>(31 - where);
- return 32; // Undefined Behavior.
-}
-
-_LIBCPP_ALWAYS_INLINE int __builtin_clz(unsigned int x)
-{
- return __builtin_clzl(x);
-}
-#endif // _LIBCPP_MSVC
-
-#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
diff --git a/include/variant b/include/variant
index 88f7b240d029..ba15ed8c4a14 100644
--- a/include/variant
+++ b/include/variant
@@ -425,30 +425,21 @@ struct __base {
constexpr auto __fmatrix =
__make_fmatrix<_Visitor&&,
decltype(_VSTD::forward<_Vs>(__vs).__as_base())...>();
- const size_t __indices[] = {__vs.index()...};
- return __at(__fmatrix, __indices)(_VSTD::forward<_Visitor>(__visitor),
- _VSTD::forward<_Vs>(__vs).__as_base()...);
+ return __at(__fmatrix, __vs.index()...)(
+ _VSTD::forward<_Visitor>(__visitor),
+ _VSTD::forward<_Vs>(__vs).__as_base()...);
}
private:
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
- static constexpr const _Tp& __at_impl(const _Tp& __elem, const size_t*) {
- return __elem;
- }
-
- template <class _Tp, size_t _Np>
- inline _LIBCPP_INLINE_VISIBILITY
- static constexpr auto&& __at_impl(const array<_Tp, _Np>& __elems,
- const size_t* __index) {
- return __at_impl(__elems[*__index], __index + 1);
- }
+ static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }
- template <class _Tp, size_t _Np, size_t _Ip>
+ template <class _Tp, size_t _Np, typename... _Indices>
inline _LIBCPP_INLINE_VISIBILITY
static constexpr auto&& __at(const array<_Tp, _Np>& __elems,
- const size_t (&__indices)[_Ip]) {
- return __at_impl(__elems, begin(__indices));
+ size_t __index, _Indices... __indices) {
+ return __at(__elems[__index], __indices...);
}
template <class _Fp, class... _Fs>
@@ -1140,7 +1131,7 @@ public:
: __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {}
template <size_t _Ip, class... _Args,
- enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
+ class = enable_if_t<(_Ip < sizeof...(_Types)), int>,
class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/include/wchar.h b/include/wchar.h
index c0c6ef754fbe..25a318faff25 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -166,9 +166,12 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
}
#endif
-#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
-extern "C++" {
-#include <support/win32/support.h> // pull in *swprintf defines
+#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT)
+extern "C" {
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+ size_t nmc, size_t len, mbstate_t *__restrict ps);
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+ size_t nwc, size_t len, mbstate_t *__restrict ps);
} // extern "C++"
#endif // __cplusplus && _LIBCPP_MSVCRT
diff --git a/src/include/atomic_support.h b/src/include/atomic_support.h
index 378541b23256..08847e630705 100644
--- a/src/include/atomic_support.h
+++ b/src/include/atomic_support.h
@@ -29,7 +29,7 @@
#endif
#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
-# if defined(_LIBCPP_MSVC)
+# if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
# else
# warning Building libc++ without __atomic builtins is unsupported
diff --git a/src/locale.cpp b/src/locale.cpp
index 1ed9b41fd4ad..4163c2c0af65 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -45,6 +45,24 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+struct __libcpp_unique_locale {
+ __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}
+
+ ~__libcpp_unique_locale() {
+ if (__loc_)
+ freelocale(__loc_);
+ }
+
+ explicit operator bool() const { return __loc_; }
+
+ locale_t& get() { return __loc_; }
+
+ locale_t __loc_;
+private:
+ __libcpp_unique_locale(__libcpp_unique_locale const&);
+ __libcpp_unique_locale& operator=(__libcpp_unique_locale const&);
+};
+
#ifdef __cloc_defined
locale_t __cloc() {
// In theory this could create a race condition. In practice
@@ -4185,7 +4203,7 @@ __widen_from_utf8<32>::~__widen_from_utf8()
static bool checked_string_to_wchar_convert(wchar_t& dest,
const char* ptr,
- __locale_struct* loc) {
+ locale_t loc) {
if (*ptr == '\0')
return false;
mbstate_t mb = {};
@@ -4200,7 +4218,7 @@ static bool checked_string_to_wchar_convert(wchar_t& dest,
static bool checked_string_to_char_convert(char& dest,
const char* ptr,
- __locale_struct* __loc) {
+ locale_t __loc) {
if (*ptr == '\0')
return false;
if (!ptr[1]) {
@@ -4295,8 +4313,8 @@ numpunct_byname<char>::__init(const char* nm)
{
if (strcmp(nm, "C") != 0)
{
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("numpunct_byname<char>::numpunct_byname"
" failed to construct for " + string(nm));
@@ -4333,8 +4351,8 @@ numpunct_byname<wchar_t>::__init(const char* nm)
{
if (strcmp(nm, "C") != 0)
{
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("numpunct_byname<wchar_t>::numpunct_byname"
" failed to construct for " + string(nm));
@@ -5820,8 +5838,8 @@ void
moneypunct_byname<char, false>::init(const char* nm)
{
typedef moneypunct<char, false> base;
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("moneypunct_byname"
" failed to construct for " + string(nm));
@@ -5864,8 +5882,8 @@ void
moneypunct_byname<char, true>::init(const char* nm)
{
typedef moneypunct<char, true> base;
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("moneypunct_byname"
" failed to construct for " + string(nm));
@@ -5924,8 +5942,8 @@ void
moneypunct_byname<wchar_t, false>::init(const char* nm)
{
typedef moneypunct<wchar_t, false> base;
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("moneypunct_byname"
" failed to construct for " + string(nm));
lconv* lc = __libcpp_localeconv_l(loc.get());
@@ -5989,8 +6007,8 @@ void
moneypunct_byname<wchar_t, true>::init(const char* nm)
{
typedef moneypunct<wchar_t, true> base;
- __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
- if (loc == nullptr)
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
__throw_runtime_error("moneypunct_byname"
" failed to construct for " + string(nm));
diff --git a/src/string.cpp b/src/string.cpp
index cd644330b3a7..d7ebdd3e5c9a 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -13,9 +13,6 @@
#include "cerrno"
#include "limits"
#include "stdexcept"
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/support.h"
-#endif // _LIBCPP_MSVCRT
#include <stdio.h>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -430,7 +427,7 @@ get_swprintf()
#ifndef _LIBCPP_MSVCRT
return swprintf;
#else
- return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(swprintf);
+ return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(_snwprintf);
#endif
}
diff --git a/src/support/runtime/exception_pointer_msvc.ipp b/src/support/runtime/exception_pointer_msvc.ipp
index a8cd0e8d304d..eab5d30a9487 100644
--- a/src/support/runtime/exception_pointer_msvc.ipp
+++ b/src/support/runtime/exception_pointer_msvc.ipp
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <yvals.h> // for _CRTIMP2_PURE
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp
index acbf79ac197c..28cb4491781f 100644
--- a/src/support/win32/locale_win32.cpp
+++ b/src/support/win32/locale_win32.cpp
@@ -13,14 +13,14 @@
#include <memory>
#include <type_traits>
-typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
-typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
+using std::__libcpp_locale_guard;
// FIXME: base currently unused. Needs manual work to construct the new locale
locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
{
return _create_locale( mask, locale );
}
+
locale_t uselocale( locale_t newloc )
{
locale_t old_locale = _get_current_locale();
@@ -36,59 +36,59 @@ locale_t uselocale( locale_t newloc )
}
lconv *localeconv_l( locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return localeconv();
}
size_t mbrlen_l( const char *__restrict s, size_t n,
mbstate_t *__restrict ps, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return mbrlen( s, n, ps );
}
size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
size_t len, mbstate_t *__restrict ps, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return mbsrtowcs( dst, src, len, ps );
}
size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return wcrtomb( s, wc, ps );
}
size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
size_t n, mbstate_t *__restrict ps, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return mbrtowc( pwc, s, n, ps );
}
size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return mbsnrtowcs( dst, src, nms, len, ps );
}
size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return wcsnrtombs( dst, src, nwc, len, ps );
}
wint_t btowc_l( int c, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return btowc( c );
}
int wctob_l( wint_t c, locale_t loc )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return wctob( c );
}
int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
va_list ap;
va_start( ap, format );
int result = vsnprintf( ret, n, format, ap );
@@ -106,6 +106,6 @@ int asprintf_l( char **ret, locale_t loc, const char *format, ... )
}
int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap )
{
- __locale_raii __current( uselocale(loc), uselocale );
+ __libcpp_locale_guard __current(loc);
return vasprintf( ret, format, ap );
}
diff --git a/src/thread.cpp b/src/thread.cpp
index 3f283c385b76..412a8fa0a620 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -99,7 +99,7 @@ thread::hardware_concurrency() _NOEXCEPT
#else // defined(CTL_HW) && defined(HW_NCPU)
// TODO: grovel through /proc or check cpuid on x86 and similar
// instructions on other architectures.
-# if defined(_LIBCPP_MSVC)
+# if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("hardware_concurrency not yet implemented")
# else
# warning hardware_concurrency not yet implemented
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp b/test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp
index 4d83296f086a..31a37229bf0c 100644
--- a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp
+++ b/test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// REQUIRES: libcpp-has-no-global-filesystem-namespace
+
#include <cstdio>
int main() {
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp b/test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp
index deca9bf5b551..248ab4d67210 100644
--- a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp
+++ b/test/libcxx/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// REQUIRES: libcpp-has-no-global-filesystem-namespace
+
#include <cstdio>
int main() {
diff --git a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
index de225fe78384..de225fe78384 100644
--- a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
+++ b/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
diff --git a/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
index 891b084dd32e..b46c2cdec6cb 100644
--- a/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
+++ b/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
@@ -35,7 +35,6 @@
void sig_action(int) {}
-#include <iostream>
int main()
{
int ec;
diff --git a/test/std/utilities/function.objects/refwrap/binary.pass.cpp b/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
index 579e81fe69e6..579e81fe69e6 100644
--- a/test/std/utilities/function.objects/refwrap/binary.pass.cpp
+++ b/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
diff --git a/test/std/utilities/function.objects/refwrap/unary.pass.cpp b/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
index 528a8f327d96..528a8f327d96 100644
--- a/test/std/utilities/function.objects/refwrap/unary.pass.cpp
+++ b/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
diff --git a/test/libcxx/utilities/template.bitset/includes.pass.cpp b/test/libcxx/utilities/template.bitset/includes.pass.cpp
new file mode 100644
index 000000000000..2e3c2812e441
--- /dev/null
+++ b/test/libcxx/utilities/template.bitset/includes.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test that <bitset> includes <cstddef>, <string>, <stdexcept> and <iosfwd>
+
+#include <bitset>
+
+#ifndef _LIBCPP_CSTDDEF
+#error <cstddef> has not been included
+#endif
+
+#ifndef _LIBCPP_STRING
+#error <string> has not been included
+#endif
+
+#ifndef _LIBCPP_STDEXCEPT
+#error <stdexcept> has not been included
+#endif
+
+#ifndef _LIBCPP_IOSFWD
+#error <iosfwd> has not been included
+#endif
+
+int main()
+{
+}
diff --git a/test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp b/test/libcxx/utilities/tuple/tuple.tuple/empty_member.pass.cpp
index 1e7243b5f501..1e7243b5f501 100644
--- a/test/std/utilities/tuple/tuple.tuple/empty_member.pass.cpp
+++ b/test/libcxx/utilities/tuple/tuple.tuple/empty_member.pass.cpp
diff --git a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp
index e267c6833ab9..bfd385a1b8e3 100644
--- a/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp
+++ b/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp
@@ -8,6 +8,12 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
+
+// GCC returns true for __is_trivially_constructible(void, int)
+// See gcc.gnu.org/PR80682
+// NOTE: This has been fixed in trunk and will be backported soon.
+// XFAIL: gcc-7, gcc-6, gcc-5, gcc-4
+
// <experimental/type_traits>
#include <experimental/type_traits>
diff --git a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg b/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg
deleted file mode 100644
index 4ea670935591..000000000000
--- a/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-if 'libcpp-has-no-global-filesystem-namespace' not in config.available_features:
- config.unsupported = True
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
index 41b14a6e5bf3..36f815a819be 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
@@ -15,7 +15,7 @@
// XFAIL: clang-3, apple-clang-7, apple-clang-8
// None of the current GCC compilers support this.
-// XFAIL: gcc
+// XFAIL: gcc-5, gcc-6
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
index 4c9da471294d..69f5ac8c9774 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
@@ -13,7 +13,7 @@
// UNSUPPORTED: sanitizer-new-delete
// FIXME change this to XFAIL.
-// UNSUPPORTED: no-aligned-allocation
+// UNSUPPORTED: no-aligned-allocation && !gcc
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
index 8e9eff9e206e..36453283caf6 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
@@ -13,7 +13,7 @@
// UNSUPPORTED: sanitizer-new-delete
// FIXME turn this into an XFAIL
-// UNSUPPORTED: no-aligned-allocation
+// UNSUPPORTED: no-aligned-allocation && !gcc
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
index 46f411d15684..228d176a27e0 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
@@ -17,7 +17,7 @@
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
-// XFAIL: no-aligned-allocation
+// XFAIL: no-aligned-allocation && !gcc
// On Windows libc++ doesn't provide its own definitions for new/delete
// but instead depends on the ones in VCRuntime. However VCRuntime does not
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
index 131deb340d2f..15bebcbcbcb8 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
@@ -10,7 +10,8 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: sanitizer-new-delete
-// XFAIL: no-aligned-allocation
+// NOTE: GCC doesn't provide the -faligned-allocation flag to test for
+// XFAIL: no-aligned-allocation && !gcc
// test operator new replacement
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
index 514e5e1044a0..b0e932c96cb0 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -14,7 +14,7 @@
// XFAIL: clang-3, apple-clang-7, apple-clang-8
// None of the current GCC compilers support this.
-// XFAIL: gcc
+// XFAIL: gcc-5, gcc-6
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
index 2dcb2dc2c578..22ea5e2fff89 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -20,7 +20,7 @@
// UNSUPPORTED: sanitizer-new-delete
// FIXME turn this into an XFAIL
-// UNSUPPORTED: no-aligned-allocation
+// UNSUPPORTED: no-aligned-allocation && !gcc
// On Windows libc++ doesn't provide its own definitions for new/delete
// but instead depends on the ones in VCRuntime. However VCRuntime does not
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
index e77b41336174..2c5c0f80b839 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -20,7 +20,7 @@
// UNSUPPORTED: sanitizer-new-delete
// FIXME turn this into an XFAIL
-// UNSUPPORTED: no-aligned-allocation
+// UNSUPPORTED: no-aligned-allocation && !gcc
// On Windows libc++ doesn't provide its own definitions for new/delete
// but instead depends on the ones in VCRuntime. However VCRuntime does not
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
index 862ec1ba66a4..b50f49dc6ca7 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -17,7 +17,8 @@
// XFAIL: with_system_cxx_lib=macosx10.7
// XFAIL: with_system_cxx_lib=macosx10.8
-// XFAIL: no-aligned-allocation
+// NOTE: gcc doesn't provide -faligned-allocation flag to test for
+// XFAIL: no-aligned-allocation && !gcc
// On Windows libc++ doesn't provide its own definitions for new/delete
// but instead depends on the ones in VCRuntime. However VCRuntime does not
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
index df3e4c1560a9..66bb613adfd0 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -10,7 +10,8 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: sanitizer-new-delete
-// XFAIL: no-aligned-allocation
+// NOTE: GCC doesn't provide a -faligned-allocation flag
+// XFAIL: no-aligned-allocation && !gcc
// test operator new replacement
diff --git a/test/std/language.support/support.types/byteops/and.assign.pass.cpp b/test/std/language.support/support.types/byteops/and.assign.pass.cpp
index dec241eb0c41..ec1c3805a6cb 100644
--- a/test/std/language.support/support.types/byteops/and.assign.pass.cpp
+++ b/test/std/language.support/support.types/byteops/and.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator &=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
int main () {
std::byte b; // not constexpr, just used in noexcept check
- constexpr std::byte b1{1};
- constexpr std::byte b8{8};
- constexpr std::byte b9{9};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
+ constexpr std::byte b9{static_cast<std::byte>(9)};
static_assert(noexcept(b &= b), "" );
diff --git a/test/std/language.support/support.types/byteops/and.pass.cpp b/test/std/language.support/support.types/byteops/and.pass.cpp
index 22da6e3e0d4c..6c5419cfc2a2 100644
--- a/test/std/language.support/support.types/byteops/and.pass.cpp
+++ b/test/std/language.support/support.types/byteops/and.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte operator&(byte l, byte r) noexcept;
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b8{8};
- constexpr std::byte b9{9};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
+ constexpr std::byte b9{static_cast<std::byte>(9)};
static_assert(noexcept(b1 & b8), "" );
diff --git a/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp b/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp
new file mode 100644
index 000000000000..157626137330
--- /dev/null
+++ b/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <test_macros.h>
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// The following compilers don't like "std::byte b1{1}"
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0
+
+int main () {
+ constexpr std::byte b{42};
+ static_assert(std::to_integer<int>(b) == 42, "");
+}
diff --git a/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
index dad692e14a6b..abfeebf2b024 100644
--- a/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
+++ b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept;
@@ -28,8 +25,8 @@ constexpr std::byte test(std::byte b) {
int main () {
std::byte b; // not constexpr, just used in noexcept check
- constexpr std::byte b2{2};
- constexpr std::byte b3{3};
+ constexpr std::byte b2{static_cast<std::byte>(2)};
+ constexpr std::byte b3{static_cast<std::byte>(3)};
static_assert(noexcept(b <<= 2), "" );
diff --git a/test/std/language.support/support.types/byteops/lshift.fail.cpp b/test/std/language.support/support.types/byteops/lshift.fail.cpp
index 6b1a68f83d25..707258c6df30 100644
--- a/test/std/language.support/support.types/byteops/lshift.fail.cpp
+++ b/test/std/language.support/support.types/byteops/lshift.fail.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
@@ -21,6 +18,6 @@
// is_integral_v<IntegerType> is true.
int main () {
- constexpr std::byte b1{1};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
constexpr std::byte b2 = b1 << 2.0f;
}
diff --git a/test/std/language.support/support.types/byteops/lshift.pass.cpp b/test/std/language.support/support.types/byteops/lshift.pass.cpp
index 39d659023ad8..15ad796cbe9e 100644
--- a/test/std/language.support/support.types/byteops/lshift.pass.cpp
+++ b/test/std/language.support/support.types/byteops/lshift.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
@@ -21,8 +18,8 @@
// is_integral_v<IntegerType> is true.
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b3{3};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b3{static_cast<std::byte>(3)};
static_assert(noexcept(b3 << 2), "" );
diff --git a/test/std/language.support/support.types/byteops/not.pass.cpp b/test/std/language.support/support.types/byteops/not.pass.cpp
index 734780f194a0..53f1d91faf23 100644
--- a/test/std/language.support/support.types/byteops/not.pass.cpp
+++ b/test/std/language.support/support.types/byteops/not.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte operator~(byte b) noexcept;
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b2{2};
- constexpr std::byte b8{8};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b2{static_cast<std::byte>(2)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
static_assert(noexcept(~b1), "" );
diff --git a/test/std/language.support/support.types/byteops/or.assign.pass.cpp b/test/std/language.support/support.types/byteops/or.assign.pass.cpp
index 75d6ab4d0a9d..bb4a84ec6c76 100644
--- a/test/std/language.support/support.types/byteops/or.assign.pass.cpp
+++ b/test/std/language.support/support.types/byteops/or.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator |=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
int main () {
std::byte b; // not constexpr, just used in noexcept check
- constexpr std::byte b1{1};
- constexpr std::byte b2{2};
- constexpr std::byte b8{8};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b2{static_cast<std::byte>(2)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
static_assert(noexcept(b |= b), "" );
diff --git a/test/std/language.support/support.types/byteops/or.pass.cpp b/test/std/language.support/support.types/byteops/or.pass.cpp
index 02c547f1dbb6..e2b734982c09 100644
--- a/test/std/language.support/support.types/byteops/or.pass.cpp
+++ b/test/std/language.support/support.types/byteops/or.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte operator|(byte l, byte r) noexcept;
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b2{2};
- constexpr std::byte b8{8};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b2{static_cast<std::byte>(2)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
static_assert(noexcept(b1 | b2), "" );
diff --git a/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
index b7e9a24f20a1..82c611cfdfcb 100644
--- a/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
+++ b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept;
@@ -28,8 +25,8 @@ constexpr std::byte test(std::byte b) {
int main () {
std::byte b; // not constexpr, just used in noexcept check
- constexpr std::byte b16{16};
- constexpr std::byte b192{192};
+ constexpr std::byte b16{static_cast<std::byte>(16)};
+ constexpr std::byte b192{static_cast<std::byte>(192)};
static_assert(noexcept(b >>= 2), "" );
diff --git a/test/std/language.support/support.types/byteops/rshift.fail.cpp b/test/std/language.support/support.types/byteops/rshift.fail.cpp
index a0309539a7a6..8e142dd90a5c 100644
--- a/test/std/language.support/support.types/byteops/rshift.fail.cpp
+++ b/test/std/language.support/support.types/byteops/rshift.fail.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator >>(byte b, IntegerType shift) noexcept;
@@ -21,6 +18,6 @@
// is_integral_v<IntegerType> is true.
int main () {
- constexpr std::byte b1{1};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
constexpr std::byte b2 = b1 >> 2.0f;
}
diff --git a/test/std/language.support/support.types/byteops/rshift.pass.cpp b/test/std/language.support/support.types/byteops/rshift.pass.cpp
index 876732545ac8..22d399130bbc 100644
--- a/test/std/language.support/support.types/byteops/rshift.pass.cpp
+++ b/test/std/language.support/support.types/byteops/rshift.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr byte operator <<(byte b, IntegerType shift) noexcept;
@@ -27,8 +24,8 @@ constexpr std::byte test(std::byte b) {
int main () {
- constexpr std::byte b100{100};
- constexpr std::byte b115{115};
+ constexpr std::byte b100{static_cast<std::byte>(100)};
+ constexpr std::byte b115{static_cast<std::byte>(115)};
static_assert(noexcept(b100 << 2), "" );
diff --git a/test/std/language.support/support.types/byteops/to_integer.fail.cpp b/test/std/language.support/support.types/byteops/to_integer.fail.cpp
index 426ceb7a67de..fb4928956f55 100644
--- a/test/std/language.support/support.types/byteops/to_integer.fail.cpp
+++ b/test/std/language.support/support.types/byteops/to_integer.fail.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr IntegerType to_integer(byte b) noexcept;
@@ -21,6 +18,6 @@
// is_integral_v<IntegerType> is true.
int main () {
- constexpr std::byte b1{1};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
auto f = std::to_integer<float>(b1);
}
diff --git a/test/std/language.support/support.types/byteops/to_integer.pass.cpp b/test/std/language.support/support.types/byteops/to_integer.pass.cpp
index 21dff0196a43..4f34363447f6 100644
--- a/test/std/language.support/support.types/byteops/to_integer.pass.cpp
+++ b/test/std/language.support/support.types/byteops/to_integer.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// template <class IntegerType>
// constexpr IntegerType to_integer(byte b) noexcept;
@@ -21,8 +18,8 @@
// is_integral_v<IntegerType> is true.
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b3{3};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b3{static_cast<std::byte>(3)};
static_assert(noexcept(std::to_integer<int>(b1)), "" );
static_assert(std::is_same<int, decltype(std::to_integer<int>(b1))>::value, "" );
diff --git a/test/std/language.support/support.types/byteops/xor.assign.pass.cpp b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
index c9b40177a17c..6a526da3d714 100644
--- a/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
+++ b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
@@ -11,9 +11,6 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte& operator ^=(byte l, byte r) noexcept;
@@ -26,9 +23,9 @@ constexpr std::byte test(std::byte b1, std::byte b2) {
int main () {
std::byte b; // not constexpr, just used in noexcept check
- constexpr std::byte b1{1};
- constexpr std::byte b8{8};
- constexpr std::byte b9{9};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
+ constexpr std::byte b9{static_cast<std::byte>(9)};
static_assert(noexcept(b ^= b), "" );
diff --git a/test/std/language.support/support.types/byteops/xor.pass.cpp b/test/std/language.support/support.types/byteops/xor.pass.cpp
index 3d0402b30a55..e8c3b9875785 100644
--- a/test/std/language.support/support.types/byteops/xor.pass.cpp
+++ b/test/std/language.support/support.types/byteops/xor.pass.cpp
@@ -11,16 +11,13 @@
#include <test_macros.h>
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
// constexpr byte operator^(byte l, byte r) noexcept;
int main () {
- constexpr std::byte b1{1};
- constexpr std::byte b8{8};
- constexpr std::byte b9{9};
+ constexpr std::byte b1{static_cast<std::byte>(1)};
+ constexpr std::byte b8{static_cast<std::byte>(8)};
+ constexpr std::byte b9{static_cast<std::byte>(9)};
static_assert(noexcept(b1 ^ b8), "" );
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
index 2eb6978b0e0a..b90c41e59d0d 100644
--- a/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
+++ b/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
@@ -25,307 +25,329 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- typedef std::codecvt_utf16<wchar_t> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xD8));
- assert(n[1] == char(0xC0));
- assert(n[2] == char(0xDC));
- assert(n[3] == char(0x03));
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0x10));
- assert(n[1] == char(0x05));
- assert(n[2] == char(0xDC));
- assert(n[3] == char(0x03));
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ // Nothing to do, the conversion in unsupported
+}
+
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ {
+ typedef std::codecvt_utf16<CharT> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xD8));
+ assert(n[1] == char(0xC0));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0x10));
+ assert(n[1] == char(0x05));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0x04));
- assert(n[1] == char(0x53));
- assert(n[2] == char(0xDC));
- assert(n[3] == char(0x03));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0x04));
+ assert(n[1] == char(0x53));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0x00));
- assert(n[1] == char(0x56));
- assert(n[2] == char(0xDC));
- assert(n[3] == char(0x03));
- }
- {
- typedef std::codecvt_utf16<wchar_t, 0x1000> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0x00));
+ assert(n[1] == char(0x56));
+ assert(n[2] == char(0xDC));
+ assert(n[3] == char(0x03));
+ }
+ {
+ typedef std::codecvt_utf16<CharT, 0x1000> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0x04));
- assert(n[1] == char(0x53));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0x04));
+ assert(n[1] == char(0x53));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0x00));
- assert(n[1] == char(0x56));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
- }
- {
- typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::generate_header> C;
- C c;
- wchar_t w = 0x40003;
- char n[6] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+6);
- assert(n[0] == char(0xFE));
- assert(n[1] == char(0xFF));
- assert(n[2] == char(0xD8));
- assert(n[3] == char(0xC0));
- assert(n[4] == char(0xDC));
- assert(n[5] == char(0x03));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0x00));
+ assert(n[1] == char(0x56));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf16<CharT, 0x10ffff, std::generate_header> C;
+ C c;
+ CharT w = 0x40003;
+ char n[6] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 6);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0xD8));
+ assert(n[3] == char(0xC0));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xFE));
- assert(n[1] == char(0xFF));
- assert(n[2] == char(0x10));
- assert(n[3] == char(0x05));
- assert(n[4] == char(0xDC));
- assert(n[5] == char(0x03));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x10));
+ assert(n[3] == char(0x05));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xFE));
- assert(n[1] == char(0xFF));
- assert(n[2] == char(0x04));
- assert(n[3] == char(0x53));
- assert(n[4] == char(0xDC));
- assert(n[5] == char(0x03));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x04));
+ assert(n[3] == char(0x53));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xFE));
- assert(n[1] == char(0xFF));
- assert(n[2] == char(0x00));
- assert(n[3] == char(0x56));
- assert(n[4] == char(0xDC));
- assert(n[5] == char(0x03));
- }
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xFE));
+ assert(n[1] == char(0xFF));
+ assert(n[2] == char(0x00));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0xDC));
+ assert(n[5] == char(0x03));
+ }
- {
- typedef std::codecvt_utf16<wchar_t, 0x10FFFF, std::little_endian> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[1] == char(0xD8));
- assert(n[0] == char(0xC0));
- assert(n[3] == char(0xDC));
- assert(n[2] == char(0x03));
+ {
+ typedef std::codecvt_utf16<CharT, 0x10FFFF, std::little_endian> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[1] == char(0xD8));
+ assert(n[0] == char(0xC0));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[1] == char(0x10));
- assert(n[0] == char(0x05));
- assert(n[3] == char(0xDC));
- assert(n[2] == char(0x03));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[1] == char(0x10));
+ assert(n[0] == char(0x05));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[1] == char(0x04));
- assert(n[0] == char(0x53));
- assert(n[3] == char(0xDC));
- assert(n[2] == char(0x03));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[1] == char(0x04));
+ assert(n[0] == char(0x53));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[1] == char(0x00));
- assert(n[0] == char(0x56));
- assert(n[3] == char(0xDC));
- assert(n[2] == char(0x03));
- }
- {
- typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[1] == char(0));
- assert(n[0] == char(0));
- assert(n[3] == char(0));
- assert(n[2] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[1] == char(0x00));
+ assert(n[0] == char(0x56));
+ assert(n[3] == char(0xDC));
+ assert(n[2] == char(0x03));
+ }
+ {
+ typedef std::codecvt_utf16<CharT, 0x1000, std::little_endian> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[1] == char(0));
+ assert(n[0] == char(0));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[1] == char(0));
- assert(n[0] == char(0));
- assert(n[3] == char(0));
- assert(n[2] == char(0));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[1] == char(0));
+ assert(n[0] == char(0));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[1] == char(0x04));
- assert(n[0] == char(0x53));
- assert(n[3] == char(0));
- assert(n[2] == char(0));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[1] == char(0x04));
+ assert(n[0] == char(0x53));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[1] == char(0x00));
- assert(n[0] == char(0x56));
- assert(n[3] == char(0));
- assert(n[2] == char(0));
- }
- {
- typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
- std::generate_header |
- std::little_endian)> C;
- C c;
- wchar_t w = 0x40003;
- char n[6] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+6);
- assert(n[1] == char(0xFE));
- assert(n[0] == char(0xFF));
- assert(n[3] == char(0xD8));
- assert(n[2] == char(0xC0));
- assert(n[5] == char(0xDC));
- assert(n[4] == char(0x03));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[1] == char(0x00));
+ assert(n[0] == char(0x56));
+ assert(n[3] == char(0));
+ assert(n[2] == char(0));
+ }
+ {
+ typedef std::codecvt_utf16<CharT, 0x10ffff,
+ std::codecvt_mode(std::generate_header |
+ std::little_endian)>
+ C;
+ C c;
+ CharT w = 0x40003;
+ char n[6] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 6);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0xD8));
+ assert(n[2] == char(0xC0));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[1] == char(0xFE));
- assert(n[0] == char(0xFF));
- assert(n[3] == char(0x10));
- assert(n[2] == char(0x05));
- assert(n[5] == char(0xDC));
- assert(n[4] == char(0x03));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x10));
+ assert(n[2] == char(0x05));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[1] == char(0xFE));
- assert(n[0] == char(0xFF));
- assert(n[3] == char(0x04));
- assert(n[2] == char(0x53));
- assert(n[5] == char(0xDC));
- assert(n[4] == char(0x03));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x04));
+ assert(n[2] == char(0x53));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 6, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[1] == char(0xFE));
+ assert(n[0] == char(0xFF));
+ assert(n[3] == char(0x00));
+ assert(n[2] == char(0x56));
+ assert(n[5] == char(0xDC));
+ assert(n[4] == char(0x03));
+ }
+}
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+6, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[1] == char(0xFE));
- assert(n[0] == char(0xFF));
- assert(n[3] == char(0x00));
- assert(n[2] == char(0x56));
- assert(n[5] == char(0xDC));
- assert(n[4] == char(0x03));
- }
+int main() {
+ TestHelper<char32_t>::test();
+ TestHelper<wchar_t>::test();
}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
index 02cf7cf958e7..886fc4416bbb 100644
--- a/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
@@ -25,432 +25,302 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- typedef std::codecvt_utf8<wchar_t> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xF1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x80));
- assert(n[3] == char(0x83));
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
- }
- {
- typedef std::codecvt_utf8<wchar_t, 0x1000> C;
- C c;
- wchar_t w = 0x40003;
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ {
+ typedef std::codecvt_utf8<CharT> C;
+ C c;
+ CharT w = 0x1005;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<CharT, 0x1000> C;
+ C c;
+ CharT w = 0x1005;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
- }
- {
- typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::generate_header> C;
- C c;
- wchar_t w = 0x40003;
- char n[7] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+7);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xF1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x80));
- assert(n[6] == char(0x83));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<CharT, 0xFFFFFFFF, std::generate_header> C;
+ C c;
+ CharT w = 0x1005;
+ char n[7] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
- }
- {
- typedef std::codecvt_utf8<char32_t> C;
- C c;
- char32_t w = 0x40003;
- char n[4] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xF1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x80));
- assert(n[3] == char(0x83));
-
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
-
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
-
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0x83));
- }
- {
- typedef std::codecvt_utf8<char32_t, 0x1000> C;
- C c;
- char32_t w = 0x40003;
- char n[4] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
-
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0));
+ }
+}
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ {
+ typedef std::codecvt_utf8<CharT> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
- }
- {
- typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::generate_header> C;
- C c;
- char32_t w = 0x40003;
- char n[7] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+7);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xF1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x80));
- assert(n[6] == char(0x83));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
- w = 0x1005;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0x85));
+ assert(n[3] == char(0x83));
+ }
+ {
+ typedef std::codecvt_utf8<CharT, 0x1000> C;
+ C c;
+ CharT w = 0x40003;
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0x83));
- }
- {
- typedef std::codecvt_utf8<char16_t> C;
- C c;
- char16_t w = 0x1005;
- char n[4] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == &w);
+ assert(np == n);
+ assert(n[0] == char(0));
+ assert(n[1] == char(0));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0x85));
- assert(n[3] == char(0));
- }
- {
- typedef std::codecvt_utf8<char16_t, 0x1000> C;
- C c;
- char16_t w = 0x1005;
- char n[4] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == &w);
- assert(np == n);
- assert(n[0] == char(0));
- assert(n[1] == char(0));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ assert(n[1] == char(0x93));
+ assert(n[2] == char(0));
+ assert(n[3] == char(0));
+ }
+ {
+ typedef std::codecvt_utf8<CharT, 0xFFFFFFFF, std::generate_header> C;
+ C c;
+ CharT w = 0x40003;
+ char n[7] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
+ w = 0x1005;
+ r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- assert(n[1] == char(0x93));
- assert(n[2] == char(0));
- assert(n[3] == char(0));
- }
- {
- typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::generate_header> C;
- C c;
- char16_t w = 0x1005;
- char n[7] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0));
+ w = 0x453;
+ r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
- w = 0x453;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0));
+ w = 0x56;
+ r = c.out(m, &w, &w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == &w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ assert(n[4] == char(0x93));
+ assert(n[5] == char(0x85));
+ assert(n[6] == char(0x83));
+ }
+}
- w = 0x56;
- r = c.out(m, &w, &w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == &w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- assert(n[4] == char(0x93));
- assert(n[5] == char(0x85));
- assert(n[6] == char(0));
- }
+int main() {
+ TestHelper<wchar_t>::test();
+ TestHelper<char32_t>::test();
+ TestHelper<char16_t>::test();
}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
index 0cd941764aa0..392d66f2298c 100644
--- a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
@@ -25,348 +25,220 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- typedef std::codecvt_utf8_utf16<wchar_t> C;
- C c;
- wchar_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- wchar_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
- C c;
- wchar_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- wchar_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header> C;
- C c;
- wchar_t w[2] = {0};
- char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
- wchar_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t> C;
- C c;
- char32_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- char32_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
- C c;
- char32_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- char32_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::consume_header> C;
- C c;
- char32_t w[2] = {0};
- char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
- char32_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char16_t> C;
- C c;
- char16_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- char16_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
- C c;
- char16_t w[2] = {0};
- char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
- char16_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
-
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
- {
- typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::consume_header> C;
- C c;
- char16_t w[2] = {0};
- char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
- char16_t* wp = nullptr;
- std::mbstate_t m;
- const char* np = nullptr;
- std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(w[0] == 0xD8C0);
- assert(w[1] == 0xDC03);
-
- n[0] = char(0xE1);
- n[1] = char(0x80);
- n[2] = char(0x85);
- r = c.in(m, n, n+3, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(w[0] == 0x1005);
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
+
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x1000> C;
+ C c;
+ CharT w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ CharT* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n + 4, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n + 3, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n + 2, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n + 1, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x10ffff, std::consume_header> C;
+ C c;
+ CharT w[2] = {0};
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1),
+ char(0x80), char(0x80), char(0x83)};
+ CharT* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n + 7, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 7);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n + 3, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n + 2, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n + 1, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(w[0] == 0x0056);
+ }
+}
- n[0] = char(0xD1);
- n[1] = char(0x93);
- r = c.in(m, n, n+2, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(w[0] == 0x0453);
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ {
+ typedef std::codecvt_utf8_utf16<CharT> C;
+ C c;
+ CharT w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ CharT* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n + 4, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 4);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n + 3, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n + 2, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n + 1, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x1000> C;
+ C c;
+ CharT w[2] = {0};
+ char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+ CharT* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n + 4, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n + 3, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n + 2, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n + 1, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(w[0] == 0x0056);
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x10ffff, std::consume_header> C;
+ C c;
+ CharT w[2] = {0};
+ char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1),
+ char(0x80), char(0x80), char(0x83)};
+ CharT* wp = nullptr;
+ std::mbstate_t m;
+ const char* np = nullptr;
+ std::codecvt_base::result r = c.in(m, n, n + 7, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 7);
+ assert(w[0] == 0xD8C0);
+ assert(w[1] == 0xDC03);
+
+ n[0] = char(0xE1);
+ n[1] = char(0x80);
+ n[2] = char(0x85);
+ r = c.in(m, n, n + 3, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 3);
+ assert(w[0] == 0x1005);
+
+ n[0] = char(0xD1);
+ n[1] = char(0x93);
+ r = c.in(m, n, n + 2, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(w[0] == 0x0453);
+
+ n[0] = char(0x56);
+ r = c.in(m, n, n + 1, np, w, w + 2, wp);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(w[0] == 0x0056);
+ }
+}
- n[0] = char(0x56);
- r = c.in(m, n, n+1, np, w, w+2, wp);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(w[0] == 0x0056);
- }
+int main() {
+#ifndef _WIN32
+ TestHelper<wchar_t>::test();
+#endif
+ TestHelper<char32_t>::test();
+ TestHelper<char16_t>::test();
}
diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
index 29c5342e4545..ced2a36a4fec 100644
--- a/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
+++ b/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
@@ -25,391 +25,285 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- typedef std::codecvt_utf8_utf16<wchar_t> C;
- C c;
- wchar_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(n[0] == char(0xF1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x80));
- assert(n[3] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
- C c;
- wchar_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::generate_header> C;
- C c;
- wchar_t w[2] = {0xD8C0, 0xDC03};
- char n[7] = {0};
- const wchar_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xF1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x80));
- assert(n[6] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t> C;
- C c;
- char32_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(n[0] == char(0xF1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x80));
- assert(n[3] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
- C c;
- char32_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::generate_header> C;
- C c;
- char32_t w[2] = {0xD8C0, 0xDC03};
- char n[7] = {0};
- const char32_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xF1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x80));
- assert(n[6] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- }
-
- {
- typedef std::codecvt_utf8_utf16<char16_t> C;
- C c;
- char16_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+4);
- assert(n[0] == char(0xF1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x80));
- assert(n[3] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+3);
- assert(n[0] == char(0xE1));
- assert(n[1] == char(0x80));
- assert(n[2] == char(0x85));
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
- C c;
- char16_t w[2] = {0xD8C0, 0xDC03};
- char n[4] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::error);
- assert(wp == w);
- assert(np == n);
-
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+2);
- assert(n[0] == char(0xD1));
- assert(n[1] == char(0x93));
-
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+4, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+1);
- assert(n[0] == char(0x56));
- }
- {
- typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::generate_header> C;
- C c;
- char16_t w[2] = {0xD8C0, 0xDC03};
- char n[7] = {0};
- const char16_t* wp = nullptr;
- std::mbstate_t m;
- char* np = nullptr;
- std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+2);
- assert(np == n+7);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xF1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x80));
- assert(n[6] == char(0x83));
-
- w[0] = 0x1005;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+6);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xE1));
- assert(n[4] == char(0x80));
- assert(n[5] == char(0x85));
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
+
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ {
+ typedef std::codecvt_utf8_utf16<CharT> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x1000> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x10ffff, std::generate_header> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[7] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ }
+}
- w[0] = 0x453;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+5);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0xD1));
- assert(n[4] == char(0x93));
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ {
+ typedef std::codecvt_utf8_utf16<CharT> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 4);
+ assert(n[0] == char(0xF1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x80));
+ assert(n[3] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 3);
+ assert(n[0] == char(0xE1));
+ assert(n[1] == char(0x80));
+ assert(n[2] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x1000> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[4] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::error);
+ assert(wp == w);
+ assert(np == n);
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 2);
+ assert(n[0] == char(0xD1));
+ assert(n[1] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 4, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 1);
+ assert(n[0] == char(0x56));
+ }
+ {
+ typedef std::codecvt_utf8_utf16<CharT, 0x10ffff, std::generate_header> C;
+ C c;
+ CharT w[2] = {0xD8C0, 0xDC03};
+ char n[7] = {0};
+ const CharT* wp = nullptr;
+ std::mbstate_t m;
+ char* np = nullptr;
+ std::codecvt_base::result r = c.out(m, w, w + 2, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 2);
+ assert(np == n + 7);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xF1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x80));
+ assert(n[6] == char(0x83));
+
+ w[0] = 0x1005;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 6);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xE1));
+ assert(n[4] == char(0x80));
+ assert(n[5] == char(0x85));
+
+ w[0] = 0x453;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 5);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0xD1));
+ assert(n[4] == char(0x93));
+
+ w[0] = 0x56;
+ r = c.out(m, w, w + 1, wp, n, n + 7, np);
+ assert(r == std::codecvt_base::ok);
+ assert(wp == w + 1);
+ assert(np == n + 4);
+ assert(n[0] == char(0xEF));
+ assert(n[1] == char(0xBB));
+ assert(n[2] == char(0xBF));
+ assert(n[3] == char(0x56));
+ }
+}
- w[0] = 0x56;
- r = c.out(m, w, w+1, wp, n, n+7, np);
- assert(r == std::codecvt_base::ok);
- assert(wp == w+1);
- assert(np == n+4);
- assert(n[0] == char(0xEF));
- assert(n[1] == char(0xBB));
- assert(n[2] == char(0xBF));
- assert(n[3] == char(0x56));
- }
+int main() {
+#ifndef _WIN32
+ TestHelper<wchar_t>::test();
+#endif
+ TestHelper<char32_t>::test();
+ TestHelper<char16_t>::test();
}
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
index 06df185757d2..480628f707e2 100644
--- a/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
@@ -17,9 +17,39 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- typedef std::codecvt_utf8<wchar_t> Codecvt;
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
+
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ typedef std::codecvt_utf8<CharT> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ Myconv myconv;
+ assert(myconv.converted() == 0);
+ std::string bs = myconv.to_bytes(L"\x1005");
+ assert(myconv.converted() == 1);
+ bs = myconv.to_bytes(L"\x1005\x65");
+ assert(myconv.converted() == 2);
+ std::wstring ws = myconv.from_bytes("\xE1\x80\x85");
+ assert(myconv.converted() == 3);
+ }
+}
+
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ typedef std::codecvt_utf8<CharT> Codecvt;
typedef std::wstring_convert<Codecvt> Myconv;
Myconv myconv;
assert(myconv.converted() == 0);
@@ -29,4 +59,7 @@ int main()
assert(myconv.converted() == 2);
std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83");
assert(myconv.converted() == 4);
+ }
}
+
+int main() { TestHelper<wchar_t>::test(); }
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
index 8705a5f3bced..2e627b739928 100644
--- a/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
@@ -20,20 +20,53 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
- std::string bs("\xF1\x80\x80\x83");
- std::wstring ws = myconv.from_bytes('a');
- assert(ws == L"a");
- ws = myconv.from_bytes(bs.c_str());
- assert(ws == L"\x40003");
- ws = myconv.from_bytes(bs);
- assert(ws == L"\x40003");
- ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
- assert(ws == L"\x40003");
- ws = myconv.from_bytes("");
- assert(ws.size() == 0);
- }
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
+
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ std::wstring_convert<std::codecvt_utf8<CharT> > myconv;
+ std::string bs("\xE1\x80\x85\x00");
+ std::wstring ws = myconv.from_bytes('a');
+ assert(ws == L"a");
+ ws = myconv.from_bytes(bs.c_str());
+ assert(ws == L"\x1005");
+ ws = myconv.from_bytes(bs);
+ assert(ws == L"\x1005");
+ ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
+ assert(ws == L"\x1005");
+ ws = myconv.from_bytes("");
+ assert(ws.size() == 0);
+ }
+}
+
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ std::wstring_convert<std::codecvt_utf8<CharT> > myconv;
+ std::string bs("\xF1\x80\x80\x83");
+ std::wstring ws = myconv.from_bytes('a');
+ assert(ws == L"a");
+ ws = myconv.from_bytes(bs.c_str());
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes(bs);
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
+ assert(ws == L"\x40003");
+ ws = myconv.from_bytes("");
+ assert(ws.size() == 0);
+ }
}
+
+int main() { TestHelper<wchar_t>::test(); }
diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
index 7253a18a70b1..0a6cab73bf9e 100644
--- a/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
+++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
@@ -20,20 +20,53 @@
#include <codecvt>
#include <cassert>
-int main()
-{
- {
- std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
- std::wstring ws(1, L'\x40003');
- std::string bs = myconv.to_bytes(ws[0]);
- assert(bs == "\xF1\x80\x80\x83");
- bs = myconv.to_bytes(ws.c_str());
- assert(bs == "\xF1\x80\x80\x83");
- bs = myconv.to_bytes(ws);
- assert(bs == "\xF1\x80\x80\x83");
- bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
- assert(bs == "\xF1\x80\x80\x83");
- bs = myconv.to_bytes(L"");
- assert(bs.size() == 0);
- }
+template <class CharT, size_t = sizeof(CharT)>
+struct TestHelper;
+template <class CharT>
+struct TestHelper<CharT, 2> {
+ static void test();
+};
+template <class CharT>
+struct TestHelper<CharT, 4> {
+ static void test();
+};
+
+template <class CharT>
+void TestHelper<CharT, 2>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ std::wstring_convert<std::codecvt_utf8<CharT> > myconv;
+ std::wstring ws(1, CharT(0x1005));
+ std::string bs = myconv.to_bytes(ws[0]);
+ assert(bs == "\xE1\x80\x85\x00");
+ bs = myconv.to_bytes(ws.c_str());
+ assert(bs == "\xE1\x80\x85\x00");
+ bs = myconv.to_bytes(ws);
+ assert(bs == "\xE1\x80\x85\x00");
+ bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
+ assert(bs == "\xE1\x80\x85\x00");
+ bs = myconv.to_bytes(L"");
+ assert(bs.size() == 0);
+ }
+}
+
+template <class CharT>
+void TestHelper<CharT, 4>::test() {
+ static_assert((std::is_same<CharT, wchar_t>::value), "");
+ {
+ std::wstring_convert<std::codecvt_utf8<CharT> > myconv;
+ std::wstring ws(1, CharT(0x40003));
+ std::string bs = myconv.to_bytes(ws[0]);
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws.c_str());
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws);
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
+ assert(bs == "\xF1\x80\x80\x83");
+ bs = myconv.to_bytes(L"");
+ assert(bs.size() == 0);
+ }
}
+
+int main() { TestHelper<wchar_t>::test(); }
diff --git a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
index 961b515ef8d8..517a62a0068f 100644
--- a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
+++ b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
@@ -16,8 +16,10 @@
#include <numeric>
#include <cassert>
+#include <climits>
+#include <cstdint>
#include <cstdlib> // for rand()
-#include <iostream>
+#include <type_traits>
constexpr struct {
int x;
@@ -36,21 +38,24 @@ constexpr struct {
template <typename Input1, typename Input2, typename Output>
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
{
- static_assert((std::is_same<Output, decltype(std::gcd(in1, in2))>::value), "" );
- static_assert((std::is_same<Output, decltype(std::gcd(in2, in1))>::value), "" );
- return out == std::gcd(in1, in2) ? true : (std::abort(), false);
+ auto value1 = static_cast<Input1>(in1);
+ auto value2 = static_cast<Input2>(in2);
+ static_assert(std::is_same_v<Output, decltype(std::gcd(value1, value2))>, "");
+ static_assert(std::is_same_v<Output, decltype(std::gcd(value2, value1))>, "");
+ assert(static_cast<Output>(out) == std::gcd(value1, value2));
+ return true;
}
template <typename Input1, typename Input2 = Input1>
constexpr bool do_test(int = 0)
{
- using S1 = typename std::make_signed<Input1>::type;
- using S2 = typename std::make_signed<Input2>::type;
- using U1 = typename std::make_unsigned<Input1>::type;
- using U2 = typename std::make_unsigned<Input2>::type;
+ using S1 = std::make_signed_t<Input1>;
+ using S2 = std::make_signed_t<Input2>;
+ using U1 = std::make_unsigned_t<Input1>;
+ using U2 = std::make_unsigned_t<Input2>;
bool accumulate = true;
for (auto TC : Cases) {
{ // Test with two signed types
@@ -103,15 +108,15 @@ int main()
assert(do_test<long>(non_cce));
assert(do_test<long long>(non_cce));
- static_assert(do_test< int8_t>(), "");
- static_assert(do_test<int16_t>(), "");
- static_assert(do_test<int32_t>(), "");
- static_assert(do_test<int64_t>(), "");
+ static_assert(do_test<std::int8_t>(), "");
+ static_assert(do_test<std::int16_t>(), "");
+ static_assert(do_test<std::int32_t>(), "");
+ static_assert(do_test<std::int64_t>(), "");
- assert(do_test< int8_t>(non_cce));
- assert(do_test<int16_t>(non_cce));
- assert(do_test<int32_t>(non_cce));
- assert(do_test<int64_t>(non_cce));
+ assert(do_test<std::int8_t>(non_cce));
+ assert(do_test<std::int16_t>(non_cce));
+ assert(do_test<std::int32_t>(non_cce));
+ assert(do_test<std::int64_t>(non_cce));
static_assert(do_test<signed char, int>(), "");
static_assert(do_test<int, signed char>(), "");
@@ -133,8 +138,8 @@ int main()
// LWG#2837
{
- auto res = std::gcd((int64_t)1234, (int32_t)-2147483648);
- static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, "");
- assert(res == 2);
+ auto res = std::gcd(static_cast<std::int64_t>(1234), INT32_MIN);
+ static_assert(std::is_same_v<decltype(res), std::int64_t>, "");
+ assert(res == 2);
}
}
diff --git a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
index 90d48398f54a..6bd8a4f1e610 100644
--- a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
+++ b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
@@ -11,12 +11,14 @@
// <numeric>
// template<class _M, class _N>
-// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
#include <numeric>
#include <cassert>
+#include <climits>
+#include <cstdint>
#include <cstdlib>
-#include <iostream>
+#include <type_traits>
constexpr struct {
int x;
@@ -34,21 +36,24 @@ constexpr struct {
};
template <typename Input1, typename Input2, typename Output>
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
{
- static_assert((std::is_same<Output, decltype(std::lcm(Input1(0), Input2(0)))>::value), "" );
- static_assert((std::is_same<Output, decltype(std::lcm(Input2(0), Input1(0)))>::value), "" );
- return out == std::lcm(in1, in2) ? true : (std::abort(), false);
+ auto value1 = static_cast<Input1>(in1);
+ auto value2 = static_cast<Input2>(in2);
+ static_assert(std::is_same_v<Output, decltype(std::lcm(value1, value2))>, "");
+ static_assert(std::is_same_v<Output, decltype(std::lcm(value2, value1))>, "");
+ assert(static_cast<Output>(out) == std::lcm(value1, value2));
+ return true;
}
template <typename Input1, typename Input2 = Input1>
constexpr bool do_test(int = 0)
{
- using S1 = typename std::make_signed<Input1>::type;
- using S2 = typename std::make_signed<Input2>::type;
- using U1 = typename std::make_unsigned<Input1>::type;
- using U2 = typename std::make_unsigned<Input2>::type;
+ using S1 = std::make_signed_t<Input1>;
+ using S2 = std::make_signed_t<Input2>;
+ using U1 = std::make_unsigned_t<Input1>;
+ using U2 = std::make_unsigned_t<Input2>;
bool accumulate = true;
for (auto TC : Cases) {
{ // Test with two signed types
@@ -101,15 +106,15 @@ int main()
assert(do_test<long>(non_cce));
assert(do_test<long long>(non_cce));
- static_assert(do_test< int8_t>(), "");
- static_assert(do_test<int16_t>(), "");
- static_assert(do_test<int32_t>(), "");
- static_assert(do_test<int64_t>(), "");
+ static_assert(do_test<std::int8_t>(), "");
+ static_assert(do_test<std::int16_t>(), "");
+ static_assert(do_test<std::int32_t>(), "");
+ static_assert(do_test<std::int64_t>(), "");
- assert(do_test< int8_t>(non_cce));
- assert(do_test<int16_t>(non_cce));
- assert(do_test<int32_t>(non_cce));
- assert(do_test<int64_t>(non_cce));
+ assert(do_test<std::int8_t>(non_cce));
+ assert(do_test<std::int16_t>(non_cce));
+ assert(do_test<std::int32_t>(non_cce));
+ assert(do_test<std::int64_t>(non_cce));
static_assert(do_test<signed char, int>(), "");
static_assert(do_test<int, signed char>(), "");
@@ -131,9 +136,9 @@ int main()
// LWG#2837
{
- auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648);
- (void) std::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN
- static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, "");
- assert(res1 == 1324997410816LL);
+ auto res1 = std::lcm(static_cast<std::int64_t>(1234), INT32_MIN);
+ (void)std::lcm(INT_MIN, 2UL); // this used to trigger UBSAN
+ static_assert(std::is_same_v<decltype(res1), std::int64_t>, "");
+ assert(res1 == 1324997410816LL);
}
}
diff --git a/test/std/re/re.traits/lookup_classname.pass.cpp b/test/std/re/re.traits/lookup_classname.pass.cpp
index 2215b9043d5b..b61f772b2df8 100644
--- a/test/std/re/re.traits/lookup_classname.pass.cpp
+++ b/test/std/re/re.traits/lookup_classname.pass.cpp
@@ -27,39 +27,61 @@ test(const char_type* A,
typename std::regex_traits<char_type>::char_class_type expected,
bool icase = false)
{
+ typedef typename std::regex_traits<char_type>::char_class_type char_class_type;
std::regex_traits<char_type> t;
typedef forward_iterator<const char_type*> F;
- assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
+ char_class_type result = t.lookup_classname(F(A), F(A + t.length(A)), icase);
+ assert(result == expected);
+}
+
+template <class char_type>
+void
+test_w(const char_type* A,
+ typename std::regex_traits<char_type>::char_class_type expected,
+ bool icase = false)
+{
+ typedef typename std::regex_traits<char_type>::char_class_type char_class_type;
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ char_class_type result = t.lookup_classname(F(A), F(A + t.length(A)), icase);
+ assert((result & expected) == expected);
+ LIBCPP_ASSERT((expected | std::regex_traits<char_type>::__regex_word) == result);
+
+ const bool matches_underscore = t.isctype('_', result);
+ if (result != expected)
+ assert(matches_underscore && "expected to match underscore");
+ else
+ assert(!matches_underscore && "should not match underscore");
}
int main()
{
// if __regex_word is not distinct from all the classes, bad things happen
// See https://bugs.llvm.org/show_bug.cgi?id=26476 for an example.
- assert((std::ctype_base::space & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::print & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::cntrl & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::upper & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::lower & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::alpha & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::digit & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::punct & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::xdigit & std::regex_traits<char>::__regex_word) == 0);
- assert((std::ctype_base::blank & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::space & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::print & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::cntrl & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::upper & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::lower & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::alpha & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::digit & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::punct & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::xdigit & std::regex_traits<char>::__regex_word) == 0);
+ LIBCPP_ASSERT((std::ctype_base::blank & std::regex_traits<char>::__regex_word) == 0);
test("d", std::ctype_base::digit);
test("D", std::ctype_base::digit);
test("d", std::ctype_base::digit, true);
test("D", std::ctype_base::digit, true);
- test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
- | std::ctype_base::upper | std::ctype_base::lower);
- test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
- | std::ctype_base::upper | std::ctype_base::lower);
- test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
- | std::ctype_base::upper | std::ctype_base::lower, true);
- test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
- | std::ctype_base::upper | std::ctype_base::lower, true);
+ test_w("w", std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test_w("W", std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test_w("w", std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test_w("W", std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
test("s", std::ctype_base::space);
test("S", std::ctype_base::space);
@@ -140,13 +162,13 @@ int main()
test(L"d", std::ctype_base::digit, true);
test(L"D", std::ctype_base::digit, true);
- test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ test_w(L"w", std::ctype_base::alnum
| std::ctype_base::upper | std::ctype_base::lower);
- test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ test_w(L"W", std::ctype_base::alnum
| std::ctype_base::upper | std::ctype_base::lower);
- test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ test_w(L"w", std::ctype_base::alnum
| std::ctype_base::upper | std::ctype_base::lower, true);
- test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ test_w(L"W", std::ctype_base::alnum
| std::ctype_base::upper | std::ctype_base::lower, true);
test(L"s", std::ctype_base::space);
diff --git a/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp b/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
index c8d14a1d0ddf..67ac43494a6e 100644
--- a/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ b/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -27,16 +27,17 @@
template <class S, class SV>
void
-test(SV sv, unsigned pos, unsigned n)
+test(SV sv, std::size_t pos, std::size_t n)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
+ typedef typename S::size_type Size;
if (pos <= sv.size())
{
- S s2(sv, pos, n);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
- unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+ std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@ test(SV sv, unsigned pos, unsigned n)
{
try
{
- S s2(sv, pos, n);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
assert(false);
}
catch (std::out_of_range&)
@@ -60,15 +61,16 @@ test(SV sv, unsigned pos, unsigned n)
template <class S, class SV>
void
-test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
+test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
{
typedef typename S::traits_type T;
+ typedef typename S::size_type Size;
if (pos <= sv.size())
{
- S s2(sv, pos, n, a);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
- unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+ std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == a);
@@ -79,7 +81,7 @@ test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
{
try
{
- S s2(sv, pos, n, a);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
assert(false);
}
catch (std::out_of_range&)
diff --git a/test/std/strings/string.view/string.view.modifiers/clear.pass.cpp b/test/std/strings/string.view/string.view.modifiers/clear.pass.cpp
deleted file mode 100644
index c1137e80acaf..000000000000
--- a/test/std/strings/string.view/string.view.modifiers/clear.pass.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-
-// <string_view>
-
-// void clear() noexcept
-
-#include <string_view>
-#include <cassert>
-
-#include "test_macros.h"
-
-template<typename CharT>
-void test ( const CharT *s, size_t len ) {
- typedef std::basic_string_view<CharT> SV;
- {
- SV sv1 ( s );
- assert ( sv1.size() == len );
- assert ( sv1.data() == s );
-
- sv1.clear ();
- assert ( sv1.data() == nullptr );
- assert ( sv1.size() == 0 );
- assert ( sv1 == SV());
- }
-}
-
-#if TEST_STD_VER > 11
-constexpr size_t test_ce ( size_t n ) {
- typedef std::basic_string_view<char> SV;
- SV sv1{ "ABCDEFGHIJKL", n };
- sv1.clear();
- return sv1.size();
-}
-#endif
-
-int main () {
- test ( "ABCDE", 5 );
- test ( "a", 1 );
- test ( "", 0 );
-
- test ( L"ABCDE", 5 );
- test ( L"a", 1 );
- test ( L"", 0 );
-
-#if TEST_STD_VER >= 11
- test ( u"ABCDE", 5 );
- test ( u"a", 1 );
- test ( u"", 0 );
-
- test ( U"ABCDE", 5 );
- test ( U"a", 1 );
- test ( U"", 0 );
-#endif
-
-#if TEST_STD_VER > 11
- static_assert ( test_ce (5) == 0, "" );
-#endif
-
-}
diff --git a/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp b/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp
new file mode 100644
index 000000000000..3406fff70610
--- /dev/null
+++ b/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// template <class Rep, class Period>
+// void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+// The std::this_thread::sleep_for test requires POSIX specific headers and
+// is therefore non-standard. For this reason the test lives under the 'libcxx'
+// subdirectory.
+
+int main()
+{
+}
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
index 0aef2af85ccf..2aa19c6188a5 100644
--- a/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
+++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
@@ -107,5 +107,11 @@ int main()
assert((a.inner_allocator() ==
std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
}
-
+// Test for LWG2782
+ {
+ static_assert(!std::is_convertible<A1<int>, A2<int>>::value, "");
+ static_assert(!std::is_convertible<
+ std::scoped_allocator_adaptor<A1<int>>,
+ std::scoped_allocator_adaptor<A2<int>>>::value, "");
+ }
}
diff --git a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
index 2b19211be9bf..aa8eb3916db9 100644
--- a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
+++ b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
@@ -416,7 +416,7 @@ void throws_in_constructor_test()
ThrowsOnCopy() = default;
bool operator()() const {
assert(false);
-#if defined(_LIBCPP_MSVC)
+#if defined(TEST_COMPILER_C1XX)
__assume(0);
#else
__builtin_unreachable();
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
index 9d5681a3db76..7516b2e3af2b 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
@@ -11,7 +11,8 @@
// class function<R(ArgTypes...)>
-// function(const function& f);
+// function(const function& f);
+// function(const function&& f);
#include <functional>
#include <memory>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
index 53476a274735..7a4678ad1cae 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
@@ -63,6 +63,7 @@ int main()
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<int>() == nullptr);
}
assert(A::count == 0);
{
@@ -70,6 +71,7 @@ int main()
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
+ assert(f.target<int>() == nullptr);
}
assert(A::count == 0);
{
@@ -77,6 +79,7 @@ int main()
assert(A::count == 1);
assert(f.target<A>());
assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<int>() == nullptr);
}
assert(A::count == 0);
{
@@ -84,6 +87,7 @@ int main()
assert(A::count == 0);
assert(f.target<int(*)(int)>());
assert(f.target<A>() == 0);
+ assert(f.target<int>() == nullptr);
}
assert(A::count == 0);
}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
index 5a0d9259c11d..eb0d0a955fc5 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -49,6 +49,10 @@ struct Bar : public Foo {
};
+struct PrivateBase : private std::enable_shared_from_this<PrivateBase> {
+};
+
+
int main()
{
{ // https://bugs.llvm.org/show_bug.cgi?id=18843
@@ -74,6 +78,12 @@ int main()
assert(p == q);
assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
}
+ {
+ typedef std::shared_ptr<PrivateBase> APtr;
+ typedef std::weak_ptr<PrivateBase> WeakAPtr;
+ APtr a1 = std::make_shared<PrivateBase>();
+ assert(a1.use_count() == 1);
+ }
// Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
// http://cplusplus.github.io/LWG/lwg-active.html#2529.
// Test two different ways:
diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
index 552c16075da7..20c9eca8e521 100644
--- a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
+++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -120,7 +120,9 @@ int main()
static_assert((!std::is_convertible<ConstFunction, Function>::value), "");
static_assert((!std::is_convertible<ConstFunction, Function*>::value), "");
static_assert((!std::is_convertible<ConstFunction, Function&>::value), "");
- static_assert((!std::is_convertible<ConstFunction, Function>::value), "");
+#if TEST_STD_VER >= 11
+ static_assert((!std::is_convertible<ConstFunction, Function&&>::value), "");
+#endif
static_assert((!std::is_convertible<Function*, ConstFunction>::value), "");
static_assert((!std::is_convertible<Function&, ConstFunction>::value), "");
static_assert((!std::is_convertible<ConstFunction, ConstFunction>::value), "");
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
index 42ecdb3b896a..0bb373c96620 100644
--- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -11,7 +11,9 @@
// is_trivially_copyable
-// XFAIL: gcc-4.9
+// These compilers have not implemented Core 2094 which makes volatile
+// qualified types trivially copyable.
+// XFAIL: clang-3, clang-4, apple-clang, gcc
#include <type_traits>
#include <cassert>
@@ -22,13 +24,13 @@ void test_is_trivially_copyable()
{
static_assert( std::is_trivially_copyable<T>::value, "");
static_assert( std::is_trivially_copyable<const T>::value, "");
- static_assert(!std::is_trivially_copyable<volatile T>::value, "");
- static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+ static_assert( std::is_trivially_copyable<volatile T>::value, "");
+ static_assert( std::is_trivially_copyable<const volatile T>::value, "");
#if TEST_STD_VER > 14
static_assert( std::is_trivially_copyable_v<T>, "");
static_assert( std::is_trivially_copyable_v<const T>, "");
- static_assert(!std::is_trivially_copyable_v<volatile T>, "");
- static_assert(!std::is_trivially_copyable_v<const volatile T>, "");
+ static_assert( std::is_trivially_copyable_v<volatile T>, "");
+ static_assert( std::is_trivially_copyable_v<const volatile T>, "");
#endif
}
diff --git a/test/std/utilities/template.bitset/includes.pass.cpp b/test/std/utilities/template.bitset/includes.pass.cpp
index 2e3c2812e441..e640a1b5b7ed 100644
--- a/test/std/utilities/template.bitset/includes.pass.cpp
+++ b/test/std/utilities/template.bitset/includes.pass.cpp
@@ -11,22 +11,27 @@
#include <bitset>
-#ifndef _LIBCPP_CSTDDEF
-#error <cstddef> has not been included
-#endif
-
-#ifndef _LIBCPP_STRING
-#error <string> has not been included
-#endif
-
-#ifndef _LIBCPP_STDEXCEPT
-#error <stdexcept> has not been included
-#endif
-
-#ifndef _LIBCPP_IOSFWD
-#error <iosfwd> has not been included
-#endif
+template <class> void test_typedef() {}
int main()
{
+ { // test for <cstddef>
+ std::ptrdiff_t p; ((void)p);
+ std::size_t s; ((void)s);
+ std::nullptr_t np; ((void)np);
+ }
+ { // test for <string>
+ std::string s; ((void)s);
+ }
+ { // test for <stdexcept>
+ std::logic_error le("blah"); ((void)le);
+ std::runtime_error re("blah"); ((void)re);
+ }
+ { // test for <iosfwd>
+ test_typedef<std::ios>();
+ test_typedef<std::wios>();
+ test_typedef<std::istream>();
+ test_typedef<std::ostream>();
+ test_typedef<std::iostream>();
+ }
}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
index fbcda44e4065..d7b184f6383c 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
@@ -15,6 +15,10 @@
// ~tuple();
+// C++17 added:
+// The destructor of tuple shall be a trivial destructor
+// if (is_trivially_destructible_v<Types> && ...) is true.
+
#include <tuple>
#include <string>
#include <cassert>
diff --git a/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp
index 2d87e7ababab..83c55e75b4d2 100644
--- a/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp
+++ b/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp
@@ -15,6 +15,10 @@
// ~pair()
+// C++17 added:
+// The destructor of pair shall be a trivial destructor
+// if (is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>) is true.
+
#include <utility>
#include <type_traits>
diff --git a/test/std/utilities/variant/variant.visit/visit.pass.cpp b/test/std/utilities/variant/variant.visit/visit.pass.cpp
index 05b58c16f3d8..316f2d22b01d 100644
--- a/test/std/utilities/variant/variant.visit/visit.pass.cpp
+++ b/test/std/utilities/variant/variant.visit/visit.pass.cpp
@@ -94,6 +94,16 @@ void test_call_operator_forwarding() {
using Fn = ForwardingCallObject;
Fn obj{};
const Fn &cobj = obj;
+ { // test call operator forwarding - no variant
+ std::visit(obj);
+ assert(Fn::check_call<>(CT_NonConst | CT_LValue));
+ std::visit(cobj);
+ assert(Fn::check_call<>(CT_Const | CT_LValue));
+ std::visit(std::move(obj));
+ assert(Fn::check_call<>(CT_NonConst | CT_RValue));
+ std::visit(std::move(cobj));
+ assert(Fn::check_call<>(CT_Const | CT_RValue));
+ }
{ // test call operator forwarding - single variant, single arg
using V = std::variant<int>;
V v(42);
diff --git a/test/support/archetypes.hpp b/test/support/archetypes.hpp
index f442b592a26f..533f5869b5ab 100644
--- a/test/support/archetypes.hpp
+++ b/test/support/archetypes.hpp
@@ -5,6 +5,7 @@
#include <cassert>
#include "test_macros.h"
+#include "test_workarounds.h"
#if TEST_STD_VER >= 11
@@ -14,7 +15,9 @@ template <bool, class T>
struct DepType : T {};
struct NullBase {
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
NullBase() = default;
NullBase(NullBase const&) = default;
NullBase& operator=(NullBase const&) = default;
@@ -81,7 +84,9 @@ struct TestBase {
++assigned; ++value_assigned;
return *this;
}
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
~TestBase() {
assert(value != -999); assert(alive > 0);
--alive; ++destroyed; value = -999;
@@ -144,7 +149,9 @@ struct ValueBase {
}
//~ValueBase() { assert(value != -999); value = -999; }
int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
constexpr static int check_value(int const& val) {
#if TEST_STD_VER < 14
return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
@@ -197,7 +204,9 @@ struct TrivialValueBase {
template <bool Dummy = true, typename std::enable_if<Dummy && !Explicit, bool>::type = true>
constexpr TrivialValueBase(std::initializer_list<int>& il, int = 0) : value(static_cast<int>(il.size())) {}
int value;
+#ifndef TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
protected:
+#endif // !TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
constexpr TrivialValueBase() noexcept : value(0) {}
};
diff --git a/test/support/archetypes.ipp b/test/support/archetypes.ipp
index d8d1e5a9330b..36045017907f 100644
--- a/test/support/archetypes.ipp
+++ b/test/support/archetypes.ipp
@@ -6,7 +6,11 @@
#define DEFINE_EXPLICIT
#endif
#ifndef DEFINE_CONSTEXPR
+#ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#define DEFINE_CONSTEXPR
+#else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
#define DEFINE_CONSTEXPR constexpr
+#endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
#endif
#ifndef DEFINE_ASSIGN_CONSTEXPR
#if TEST_STD_VER >= 14
diff --git a/test/support/filesystem_dynamic_test_helper.py b/test/support/filesystem_dynamic_test_helper.py
index d2b2810d0992..081e678b6e84 100644
--- a/test/support/filesystem_dynamic_test_helper.py
+++ b/test/support/filesystem_dynamic_test_helper.py
@@ -25,7 +25,7 @@ def sanitize(p):
"""
Some of the tests restrict permissions to induce failures.
-Before we delete the test enviroment, we have to walk it and re-raise the
+Before we delete the test environment, we have to walk it and re-raise the
permissions.
"""
def clean_recursive(root_p):
diff --git a/test/support/filesystem_test_helper.hpp b/test/support/filesystem_test_helper.hpp
index 6cc0e370a786..755be90351ff 100644
--- a/test/support/filesystem_test_helper.hpp
+++ b/test/support/filesystem_test_helper.hpp
@@ -227,7 +227,7 @@ private:
}
static inline void fs_helper_run(std::string const& raw_cmd) {
- // check that the fs test root in the enviroment matches what we were
+ // check that the fs test root in the environment matches what we were
// compiled with.
static bool checked = checkDynamicTestRoot();
((void)checked);
@@ -246,7 +246,7 @@ private:
std::abort();
}
if (std::string(fs_root) != LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT) {
- std::printf("ERROR: LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT enviroment variable"
+ std::printf("ERROR: LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT environment variable"
" must have the same value as when the test was compiled.\n");
std::printf(" Current Value: '%s'\n", fs_root);
std::printf(" Expected Value: '%s'\n", LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT);
diff --git a/test/support/msvc_stdlib_force_include.hpp b/test/support/msvc_stdlib_force_include.hpp
index 2b78e507a327..6bcc97952199 100644
--- a/test/support/msvc_stdlib_force_include.hpp
+++ b/test/support/msvc_stdlib_force_include.hpp
@@ -13,11 +13,13 @@
// 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
+#ifndef _LIBCXX_IN_DEVCRT
+ // Silence warnings about CRT machinery.
+ #define _CRT_SECURE_NO_WARNINGS
-// Avoid assertion dialogs.
-#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+ // Avoid assertion dialogs.
+ #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+#endif // _LIBCXX_IN_DEVCRT
#include <crtdbg.h>
#include <stdlib.h>
@@ -31,6 +33,7 @@
#define _MSVC_STL_VER 42
#endif
+#ifndef _LIBCXX_IN_DEVCRT
struct AssertionDialogAvoider {
AssertionDialogAvoider() {
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
@@ -42,6 +45,7 @@ struct AssertionDialogAvoider {
};
const AssertionDialogAvoider assertion_dialog_avoider{};
+#endif // _LIBCXX_IN_DEVCRT
// MSVC frontend only configurations
#if !defined(__clang__)
@@ -66,16 +70,18 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
// MSVC has quick_exit() and at_quick_exit().
#define _LIBCPP_HAS_QUICK_EXIT
-// atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
-#define _ENABLE_ATOMIC_ALIGNMENT_FIX
+#ifndef _LIBCXX_IN_DEVCRT
+ // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
+ #define _ENABLE_ATOMIC_ALIGNMENT_FIX
-// Enable features that /std:c++latest removes by default.
-#define _HAS_AUTO_PTR_ETC 1
-#define _HAS_FUNCTION_ASSIGN 1
-#define _HAS_OLD_IOSTREAMS_MEMBERS 1
+ // Enable features that /std:c++latest removes by default.
+ #define _HAS_AUTO_PTR_ETC 1
+ #define _HAS_FUNCTION_ASSIGN 1
+ #define _HAS_OLD_IOSTREAMS_MEMBERS 1
-// Silence warnings about raw pointers and other unchecked iterators.
-#define _SCL_SECURE_NO_WARNINGS
+ // Silence warnings about raw pointers and other unchecked iterators.
+ #define _SCL_SECURE_NO_WARNINGS
+#endif // _LIBCXX_IN_DEVCRT
#include <ciso646>
diff --git a/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp b/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
new file mode 100644
index 000000000000..856574dbcf23
--- /dev/null
+++ b/test/support/test.workarounds/c1xx_broken_za_ctor_check.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK.
+
+#include <type_traits>
+
+#include "test_workarounds.h"
+
+struct X {
+ X(int) {}
+
+ X(X&&) = default;
+ X& operator=(X&&) = default;
+
+private:
+ X(const X&) = default;
+ X& operator=(const X&) = default;
+};
+
+void PushFront(X&&) {}
+
+template<class T = int>
+auto test(int) -> decltype(PushFront(std::declval<T>()), std::true_type{});
+auto test(long) -> std::false_type;
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK)
+ static_assert(!decltype(test(0))::value, "");
+#else
+ static_assert(decltype(test(0))::value, "");
+#endif
+}
diff --git a/test/support/test_macros.h b/test/support/test_macros.h
index 46fcb66fecfc..6b573d40fe68 100644
--- a/test/support/test_macros.h
+++ b/test/support/test_macros.h
@@ -52,10 +52,12 @@
#define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
#endif
-#if defined(__clang__)
-#define TEST_COMPILER_CLANG
+#if defined(__EDG__)
+# define TEST_COMPILER_EDG
+#elif defined(__clang__)
+# define TEST_COMPILER_CLANG
# if defined(__apple_build_version__)
-# define TEST_COMPILER_APPLE_CLANG
+# define TEST_COMPILER_APPLE_CLANG
# endif
#elif defined(_MSC_VER)
# define TEST_COMPILER_C1XX
diff --git a/test/support/test_workarounds.h b/test/support/test_workarounds.h
index b24c883902e8..614cec7aab86 100644
--- a/test/support/test_workarounds.h
+++ b/test/support/test_workarounds.h
@@ -13,9 +13,16 @@
#include "test_macros.h"
+#if defined(TEST_COMPILER_EDG)
+# define TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
+#endif
+
#if defined(TEST_COMPILER_C1XX)
# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+# ifndef _MSC_EXTENSIONS
+# define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK
+# endif
#endif
#endif // SUPPORT_TEST_WORKAROUNDS_H
diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py
index 7f1ae851b9ce..25553c70da31 100644
--- a/utils/libcxx/test/config.py
+++ b/utils/libcxx/test/config.py
@@ -67,7 +67,7 @@ class Configuration(object):
self.abi_library_root = None
self.link_shared = self.get_lit_bool('enable_shared', default=True)
self.debug_build = self.get_lit_bool('debug_build', default=False)
- self.exec_env = {}
+ self.exec_env = dict(os.environ)
self.use_target = False
self.use_system_cxx_lib = False
self.use_clang_verify = False
@@ -160,7 +160,11 @@ class Configuration(object):
# Print as list to prevent "set([...])" from being printed.
self.lit_config.note('Using available_features: %s' %
list(self.config.available_features))
- self.lit_config.note('Using environment: %r' % self.exec_env)
+ show_env_vars = {}
+ for k,v in self.exec_env.items():
+ if k not in os.environ or os.environ[k] != v:
+ show_env_vars[k] = v
+ self.lit_config.note('Adding environment variables: %r' % show_env_vars)
sys.stderr.flush() # Force flushing to avoid broken output on Windows
def get_test_format(self):
@@ -546,6 +550,7 @@ class Configuration(object):
def configure_compile_flags_header_includes(self):
support_path = os.path.join(self.libcxx_src_root, 'test', 'support')
+ self.configure_config_site_header()
if self.cxx_stdlib_under_test != 'libstdc++' and \
not self.is_windows:
self.cxx.compile_flags += [
@@ -561,7 +566,6 @@ class Configuration(object):
'-include', os.path.join(support_path,
'set_windows_crt_report_mode.h')
]
- self.configure_config_site_header()
cxx_headers = self.get_lit_conf('cxx_headers')
if cxx_headers == '' or (cxx_headers is None
and self.cxx_stdlib_under_test != 'libc++'):
@@ -868,6 +872,9 @@ class Configuration(object):
# FIXME: Enable the two warnings below.
self.cxx.addWarningFlagIfSupported('-Wno-conversion')
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
+ # FIXME: Remove this warning once the min/max handling patch lands
+ # See https://reviews.llvm.org/D33080
+ self.cxx.addWarningFlagIfSupported('-Wno-#warnings')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode
@@ -1002,18 +1009,8 @@ class Configuration(object):
sub.append(('%link', link_str))
sub.append(('%build', build_str))
# Configure exec prefix substitutions.
- exec_env_str = ''
- if not self.is_windows and len(self.exec_env) != 0:
- exec_env_str = 'env '
- for k, v in self.exec_env.items():
- exec_env_str += ' %s=%s' % (k, v)
# Configure run env substitution.
- exec_str = exec_env_str
- if self.lit_config.useValgrind:
- exec_str = ' '.join(self.lit_config.valgrindArgs) + exec_env_str
- sub.append(('%exec', exec_str))
- # Configure run shortcut
- sub.append(('%run', exec_str + ' %t.exe'))
+ sub.append(('%run', '%t.exe'))
# Configure not program substitutions
not_py = os.path.join(self.libcxx_src_root, 'utils', 'not.py')
not_str = '%s %s ' % (pipes.quote(sys.executable), pipes.quote(not_py))
diff --git a/utils/libcxx/test/executor.py b/utils/libcxx/test/executor.py
index 4a189174d915..0ccf96caa8ba 100644
--- a/utils/libcxx/test/executor.py
+++ b/utils/libcxx/test/executor.py
@@ -38,36 +38,11 @@ class LocalExecutor(Executor):
def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
cmd = cmd or [exe_path]
- env_cmd = []
- if env:
- env_cmd += ['env']
- env_cmd += ['%s=%s' % (k, v) for k, v in env.items()]
if work_dir == '.':
work_dir = os.getcwd()
- if not self.is_windows:
- out, err, rc = executeCommand(env_cmd + cmd, cwd=work_dir)
- else:
- out, err, rc = executeCommand(cmd, cwd=work_dir,
- env=self._build_windows_env(env))
- return (env_cmd + cmd, out, err, rc)
-
- def _build_windows_env(self, exec_env):
- # FIXME: Finding Windows DLL's at runtime requires modifying the
- # PATH environment variables. However we don't want to print out
- # the entire PATH as part of the diagnostic for every failing test.
- # Therefore this hack builds a new executable environment that
- # merges the current environment and the supplied environment while
- # still only printing the supplied environment in diagnostics.
- if not self.is_windows or exec_env is None:
- return None
- new_env = dict(os.environ)
- for key, value in exec_env.items():
- if key == 'PATH':
- assert value.strip() != '' and "expected non-empty path"
- new_env['PATH'] = "%s;%s" % (value, os.environ['PATH'])
- else:
- new_env[key] = value
- return new_env
+ out, err, rc = executeCommand(cmd, cwd=work_dir, env=env)
+ return (cmd, out, err, rc)
+
class PrefixExecutor(Executor):
"""Prefix an executor with some other command wrapper.
diff --git a/utils/libcxx/test/format.py b/utils/libcxx/test/format.py
index c3bc97187ad4..3ac5472b4720 100644
--- a/utils/libcxx/test/format.py
+++ b/utils/libcxx/test/format.py
@@ -139,7 +139,7 @@ class LibcxxTestFormat(object):
# We can't run ShTest tests with a executor yet.
# For now, bail on trying to run them
return lit.Test.UNSUPPORTED, 'ShTest format not yet supported'
- test.config.enviroment = dict(self.exec_env)
+ test.config.environment = dict(self.exec_env)
return lit.TestRunner._runShTest(test, lit_config,
self.execute_external, script,
tmpBase)
diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html
index 867a6c41f9ad..101ad43212e5 100644
--- a/www/cxx1z_status.html
+++ b/www/cxx1z_status.html
@@ -387,7 +387,7 @@
<tr><td><a href="http://wg21.link/LWG2584">2584</a></td><td><regex> ECMAScript IdentityEscape is ambiguous</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2588">2588</a></td><td>[fund.ts.v2] "Convertible to bool" requirement in conjunction and disjunction</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2589">2589</a></td><td>match_results can't satisfy the requirements of a container</td><td>Issaquah</td><td>Complete</td></tr>
- <tr><td><a href="http://wg21.link/LWG2591">2591</a></td><td>std::function's member template target() should not lead to undefined behaviour</td><td>Issaquah</td><td></td></tr>
+ <tr><td><a href="http://wg21.link/LWG2591">2591</a></td><td>std::function's member template target() should not lead to undefined behaviour</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2598">2598</a></td><td>addressof works on temporaries</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2664">2664</a></td><td>operator/ (and other append) semantics not useful if argument has root</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2665">2665</a></td><td>remove_filename() post condition is incorrect</td><td>Issaquah</td><td>Complete</td></tr>
@@ -437,7 +437,7 @@
<tr><td><a href="http://wg21.link/LWG2768">2768</a></td><td>any_cast and move semantics</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2769">2769</a></td><td>Redundant const in the return type of any_cast(const any&amp;)</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2781">2781</a></td><td>Contradictory requirements for std::function and std::reference_wrapper</td><td>Kona</td><td>Complete</td></tr>
- <tr><td><a href="http://wg21.link/LWG2782">2782</a></td><td>scoped_allocator_adaptor constructors must be constrained</td><td>Kona</td><td></td></tr>
+ <tr><td><a href="http://wg21.link/LWG2782">2782</a></td><td>scoped_allocator_adaptor constructors must be constrained</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2784">2784</a></td><td>Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parse</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2785">2785</a></td><td>quoted should work with basic_string_view</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2786">2786</a></td><td>Annex C should mention shared_ptr changes for array support</td><td>Kona</td><td>Complete</td></tr>
@@ -447,7 +447,7 @@
<tr><td><a href="http://wg21.link/LWG2790">2790</a></td><td>Missing specification of istreambuf_iterator::operator-&gt;</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2794">2794</a></td><td>Missing requirements for allocator pointers</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2795">2795</a></td><td>&sect;[global.functions] provides incorrect example of ADL use</td><td>Kona</td><td>Complete</td></tr>
- <tr><td><a href="http://wg21.link/LWG2796">2796</a></td><td>tuple should be a literal type</td><td>Kona</td><td></td></tr>
+ <tr><td><a href="http://wg21.link/LWG2796">2796</a></td><td>tuple should be a literal type</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2801">2801</a></td><td>Default-constructibility of unique_ptr</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2802">2802</a></td><td>shared_ptr constructor requirements for a deleter</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://wg21.link/LWG2804">2804</a></td><td>Unconditional constexpr default constructor for istream_iterator</td><td>Kona</td><td>Complete</td></tr>
@@ -461,7 +461,7 @@
<tr><td><a href="http://wg21.link/LWG2837">2837</a></td><td>gcd and lcm should support a wider range of input values</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2838">2838</a></td><td>is_literal_type specification needs a little cleanup</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2842">2842</a></td><td>in_place_t check for optional::optional(U&amp;&amp;) should decay U</td><td>Kona</td><td>Complete</td></tr>
- <tr><td><a href="http://wg21.link/LWG2850">2850</a></td><td>std::function move constructor does unnecessary work</td><td>Kona</td><td></td></tr>
+ <tr><td><a href="http://wg21.link/LWG2850">2850</a></td><td>std::function move constructor does unnecessary work</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2853">2853</a></td><td>Possible inconsistency in specification of erase in [vector.modifiers]</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2855">2855</a></td><td>std::throw_with_nested("string_literal")</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://wg21.link/LWG2857">2857</a></td><td>{variant,optional,any}::emplace should return the constructed value</td><td>Kona</td><td>Complete</td></tr>
@@ -489,7 +489,7 @@
<!-- <tr><td></td><td></td><td></td><td></td></tr> -->
</table>
- <p>Last Updated: 17-Apr-2017</p>
+ <p>Last Updated: 11-May-2017</p>
</div>
</body>
</html>