From edb11085302f80f38c9d976f003aa1c9002c7abb Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 1 Jun 2017 20:59:10 +0000 Subject: Vendor import of libc++ trunk r304460: https://llvm.org/svn/llvm-project/libcxx/trunk@304460 --- appveyor-reqs-install.cmd | 2 +- include/__bit_reference | 8 +- include/__config | 34 ++- include/__hash_table | 10 +- include/__locale | 4 +- include/__mutex_base | 8 +- include/__split_buffer | 9 +- include/__std_stream | 8 +- include/__string | 8 +- include/__threading_support | 7 +- include/__tree | 8 +- include/__undef_macros | 34 +++ include/__undef_min_max | 33 --- include/algorithm | 12 +- include/array | 2 + include/bitset | 14 +- include/chrono | 8 +- include/deque | 14 +- include/experimental/algorithm | 9 +- include/experimental/dynarray | 5 + include/experimental/functional | 9 +- include/experimental/memory_resource | 5 + include/experimental/numeric | 6 + include/experimental/optional | 28 +- include/experimental/string_view | 5 + include/forward_list | 9 +- include/fstream | 8 +- include/istream | 8 +- include/limits | 25 +- include/list | 8 +- include/locale | 25 +- include/memory | 30 ++- include/module.modulemap | 2 +- include/mutex | 8 +- include/numeric | 5 + include/optional | 7 +- include/random | 226 ++++++++-------- include/ratio | 8 +- include/regex | 8 +- include/shared_mutex | 8 +- include/sstream | 8 +- include/stdexcept | 6 +- include/stdio.h | 3 +- include/streambuf | 5 + include/string | 16 +- include/string_view | 11 +- include/support/win32/locale_win32.h | 15 +- include/thread | 5 + include/tuple | 80 +++--- include/valarray | 8 +- include/vector | 8 +- include/wchar.h | 2 +- src/chrono.cpp | 2 +- src/condition_variable.cpp | 1 + src/ios.cpp | 1 + src/locale.cpp | 1 + src/mutex.cpp | 1 + src/new.cpp | 4 +- src/strstream.cpp | 1 + src/support/win32/locale_win32.cpp | 24 ++ src/support/win32/support.cpp | 11 - src/system_error.cpp | 2 +- src/thread.cpp | 2 +- test/libcxx/min_max_macros.sh.cpp | 298 +++++++++++++++++++++ .../diagnose_reference_binding.fail.cpp | 4 +- .../operator_bool.pass.cpp | 58 ++++ .../coroutine.handle.capacity/operator_bool.sh.cpp | 62 ----- .../coroutine.handle.compare/equal_comp.pass.cpp | 60 +++++ .../coroutine.handle.compare/equal_comp.sh.cpp | 64 ----- .../coroutine.handle.compare/less_comp.pass.cpp | 69 +++++ .../coroutine.handle.compare/less_comp.sh.cpp | 73 ----- .../coroutine.handle.completion/done.pass.cpp | 44 +++ .../coroutine.handle.completion/done.sh.cpp | 48 ---- .../coroutine.handle.con/assign.pass.cpp | 54 ++++ .../coroutine.handle.con/assign.sh.cpp | 58 ---- .../coroutine.handle.con/construct.pass.cpp | 53 ++++ .../coroutine.handle.con/construct.sh.cpp | 57 ---- .../coroutine.handle.export/address.pass.cpp | 51 ++++ .../coroutine.handle.export/address.sh.cpp | 55 ---- .../coroutine.handle.export/from_address.pass.cpp | 46 ++++ .../coroutine.handle.export/from_address.sh.cpp | 50 ---- .../coroutine.handle.hash/hash.pass.cpp | 63 +++++ .../coroutine.handle.hash/hash.sh.cpp | 67 ----- .../coroutine.handle.prom/promise.pass.cpp | 49 ++++ .../coroutine.handle.prom/promise.sh.cpp | 53 ---- .../coroutine.handle.resumption/destroy.pass.cpp | 61 +++++ .../coroutine.handle.resumption/destroy.sh.cpp | 65 ----- .../coroutine.handle.resumption/resume.pass.cpp | 80 ++++++ .../coroutine.handle.resumption/resume.sh.cpp | 84 ------ .../coroutine.handle/void_handle.pass.cpp | 51 ++++ .../coroutine.handle/void_handle.sh.cpp | 55 ---- .../coroutine.traits/promise_type.pass.cpp | 77 ++++++ .../coroutine.traits/promise_type.sh.cpp | 81 ------ .../suspend_always.pass.cpp | 73 +++++ .../suspend_always.sh.cpp | 73 ----- .../suspend_never.pass.cpp | 75 ++++++ .../suspend_never.sh.cpp | 75 ------ .../end.to.end/await_result.pass.cpp | 69 +++++ .../end.to.end/await_result.sh.cpp | 72 ----- .../end.to.end/bool_await_suspend.pass.cpp | 66 +++++ .../end.to.end/bool_await_suspend.sh.cpp | 73 ----- .../end.to.end/expected.pass.cpp | 89 ++++++ .../support.coroutines/end.to.end/expected.sh.cpp | 93 ------- .../end.to.end/fullexpr-dtor.pass.cpp | 117 ++++++++ .../end.to.end/fullexpr-dtor.sh.cpp | 120 --------- .../end.to.end/generator.pass.cpp | 100 +++++++ .../support.coroutines/end.to.end/generator.sh.cpp | 107 -------- .../support.coroutines/end.to.end/go.pass.cpp | 176 ++++++++++++ .../support.coroutines/end.to.end/go.sh.cpp | 182 ------------- .../end.to.end/multishot_func.pass.cpp | 87 ++++++ .../end.to.end/multishot_func.sh.cpp | 91 ------- .../end.to.end/oneshot_func.pass.cpp | 83 ++++++ .../end.to.end/oneshot_func.sh.cpp | 87 ------ .../support.coroutines/includes.pass.cpp | 25 ++ .../support.coroutines/includes.sh.cpp | 31 --- test/support/nasty_macros.hpp | 8 + test/support/test_macros.h | 2 +- utils/libcxx/test/config.py | 6 +- 118 files changed, 2644 insertions(+), 2218 deletions(-) create mode 100644 include/__undef_macros delete mode 100644 include/__undef_min_max create mode 100644 test/libcxx/min_max_macros.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/await_result.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/expected.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/expected.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/generator.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/go.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/go.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.sh.cpp create mode 100644 test/std/experimental/language.support/support.coroutines/includes.pass.cpp delete mode 100644 test/std/experimental/language.support/support.coroutines/includes.sh.cpp diff --git a/appveyor-reqs-install.cmd b/appveyor-reqs-install.cmd index 3a2087af51fee..e5b30cf43f3aa 100644 --- a/appveyor-reqs-install.cmd +++ b/appveyor-reqs-install.cmd @@ -9,7 +9,7 @@ cd C:\projects\deps :: 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 + appveyor DownloadFile http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r303050-win32.exe -FileName llvm-installer.exe ) if "%CLANG_VERSION%"=="ToT" ( START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM" diff --git a/include/__bit_reference b/include/__bit_reference index 9aea961452845..3e4a21d261ff7 100644 --- a/include/__bit_reference +++ b/include/__bit_reference @@ -14,12 +14,14 @@ #include <__config> #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template class __bit_iterator; @@ -1273,4 +1275,6 @@ private: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___BIT_REFERENCE diff --git a/include/__config b/include/__config index 32e542bd1fd71..212a2d53136bb 100644 --- a/include/__config +++ b/include/__config @@ -220,10 +220,12 @@ #endif // __NetBSD__ #if defined(_WIN32) -# define _LIBCPP_WIN32API 1 +# define _LIBCPP_WIN32API # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # define _LIBCPP_SHORT_WCHAR 1 +// Both MinGW and native MSVC provide a "MSVC"-like enviroment +# define _LIBCPP_MSVCRT_LIKE // If mingw not explicitly detected, assume using MS C runtime only. # ifndef __MINGW32__ # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library @@ -1205,4 +1207,34 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE #endif +#if defined(_LIBCPP_COMPILER_IBM) +#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO +#endif + +#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) +# define _LIBCPP_PUSH_MACROS +# define _LIBCPP_POP_MACROS +#else + // Don't warn about macro conflicts when we can restore them at the + // end of the header. +# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS +# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS +# endif +# if defined(_LIBCPP_COMPILER_MSVC) +# define _LIBCPP_PUSH_MACROS \ + __pragma(push_macro("min")) \ + __pragma(push_macro("max")) +# define _LIBCPP_POP_MACROS \ + __pragma(pop_macro("min")) \ + __pragma(pop_macro("max")) +# else +# define _LIBCPP_PUSH_MACROS \ + _Pragma("push_macro(\"min\")") \ + _Pragma("push_macro(\"max\")") +# define _LIBCPP_POP_MACROS \ + _Pragma("pop_macro(\"min\")") \ + _Pragma("pop_macro(\"max\")") +# endif +#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) + #endif // _LIBCPP_CONFIG diff --git a/include/__hash_table b/include/__hash_table index acdc443a640a8..79336ff793ec7 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -20,16 +20,17 @@ #include #include -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_CXX03_LANG template @@ -2667,6 +2668,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, } #endif // _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP__HASH_TABLE diff --git a/include/__locale b/include/__locale index cf3ba23b9092f..766842294ca38 100644 --- a/include/__locale +++ b/include/__locale @@ -19,7 +19,7 @@ #include #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#if defined(_LIBCPP_MSVCRT_LIKE) # include #elif defined(_AIX) # include @@ -367,7 +367,7 @@ public: static const mask punct = _ISpunct; static const mask xdigit = _ISxdigit; static const mask blank = _ISblank; -#elif defined(_LIBCPP_MSVCRT) +#elif defined(_LIBCPP_MSVCRT_LIKE) typedef unsigned short mask; static const mask space = _SPACE; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; diff --git a/include/__mutex_base b/include/__mutex_base index 7f5e2ea2810e0..159acd626618c 100644 --- a/include/__mutex_base +++ b/include/__mutex_base @@ -15,12 +15,16 @@ #include #include #include <__threading_support> -#include <__undef_min_max> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS @@ -428,4 +432,6 @@ condition_variable::wait_for(unique_lock& __lk, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MUTEX_BASE diff --git a/include/__split_buffer b/include/__split_buffer index 72073f024cd29..1daa4e5ada3dd 100644 --- a/include/__split_buffer +++ b/include/__split_buffer @@ -6,12 +6,14 @@ #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -628,7 +630,8 @@ swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) __x.swap(__y); } - _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_SPLIT_BUFFER diff --git a/include/__std_stream b/include/__std_stream index fb5a346f10d86..db90795f66fcb 100644 --- a/include/__std_stream +++ b/include/__std_stream @@ -17,12 +17,14 @@ #include <__locale> #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD static const int __limit = 8; @@ -355,4 +357,6 @@ __stdoutbuf<_CharT>::imbue(const locale& __loc) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___STD_STREAM diff --git a/include/__string b/include/__string index 75608cea71d9c..d30c7fddc8d65 100644 --- a/include/__string +++ b/include/__string @@ -57,14 +57,16 @@ template <> struct char_traits; #include // For EOF. #include // for __murmur2_or_cityhash -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // char_traits @@ -870,4 +872,6 @@ struct __quoted_output_proxy _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___STRING diff --git a/include/__threading_support b/include/__threading_support index afd7cb506492e..5d4c907966ee5 100644 --- a/include/__threading_support +++ b/include/__threading_support @@ -30,9 +30,12 @@ #include #include #include -#include <__undef_min_max> #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS @@ -629,6 +632,8 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !_LIBCPP_HAS_NO_THREADS #endif // _LIBCPP_THREADING_SUPPORT diff --git a/include/__tree b/include/__tree index 6771589bbc688..792870aa6ebca 100644 --- a/include/__tree +++ b/include/__tree @@ -17,12 +17,14 @@ #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template class __tree; @@ -2685,4 +2687,6 @@ swap(__tree<_Tp, _Compare, _Allocator>& __x, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___TREE diff --git a/include/__undef_macros b/include/__undef_macros new file mode 100644 index 0000000000000..60ab1dbfb5f7f --- /dev/null +++ b/include/__undef_macros @@ -0,0 +1,34 @@ +// -*- C++ -*- +//===------------------------ __undef_macros ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#ifdef min +#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) +#if defined(_LIBCPP_WARNING) +_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " + "before any Windows header. #undefing min") +#else +#warning: macro min is incompatible with C++. #undefing min +#endif +#endif +#undef min +#endif + +#ifdef max +#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) +#if defined(_LIBCPP_WARNING) +_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " + "before any Windows header. #undefing max") +#else +#warning: macro max is incompatible with C++. #undefing max +#endif +#endif +#undef max +#endif diff --git a/include/__undef_min_max b/include/__undef_min_max deleted file mode 100644 index 71db3965e3cdd..0000000000000 --- a/include/__undef_min_max +++ /dev/null @@ -1,33 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -#ifdef min -#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) -#if defined(_LIBCPP_WARNING) -_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " - "before any Windows header. #undefing min") -#else -#warning: macro min is incompatible with C++. #undefing min -#endif -#endif -#undef min -#endif - -#ifdef max -#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) -#if defined(_LIBCPP_WARNING) -_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " - "before any Windows header. #undefing max") -#else -#warning: macro max is incompatible with C++. #undefing max -#endif -#endif -#undef max -#endif diff --git a/include/algorithm b/include/algorithm index 7ea4474a1bb4f..9fe0361e577d4 100644 --- a/include/algorithm +++ b/include/algorithm @@ -651,14 +651,16 @@ template #include #endif -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // I'd like to replace these with _VSTD::equal_to, but can't because: @@ -2908,11 +2910,11 @@ struct __log2_imp<0, _Rp> static const size_t value = _Rp + 1; }; -template +template struct __log2 { static const size_t value = __log2_imp<_Xp, - sizeof(_UI) * __CHAR_BIT__ - 1>::value; + sizeof(_UIntType) * __CHAR_BIT__ - 1>::value; }; template @@ -5904,4 +5906,6 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_ALGORITHM diff --git a/include/array b/include/array index 31f5501b9bc4d..79f7e0d62c565 100644 --- a/include/array +++ b/include/array @@ -113,6 +113,8 @@ template const T&& get(const array&&) noexce #pragma GCC system_header #endif + + _LIBCPP_BEGIN_NAMESPACE_STD template diff --git a/include/bitset b/include/bitset index b49c93ce2224c..583122fbfdab0 100644 --- a/include/bitset +++ b/include/bitset @@ -113,10 +113,6 @@ template struct hash>; */ -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #include <__config> #include <__bit_reference> #include @@ -126,7 +122,13 @@ template struct hash>; #include #include <__functional_base> -#include <__undef_min_max> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD @@ -1090,4 +1092,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x); _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_BITSET diff --git a/include/chrono b/include/chrono index 657808736d091..4b793c760559f 100644 --- a/include/chrono +++ b/include/chrono @@ -305,12 +305,14 @@ constexpr chrono::duration operator "" ns(long doub #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono @@ -1160,4 +1162,6 @@ namespace chrono { // hoist the literals into namespace std::chrono _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_CHRONO diff --git a/include/deque b/include/deque index bd4316412f607..f795b489edc64 100644 --- a/include/deque +++ b/include/deque @@ -150,10 +150,6 @@ template */ -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #include <__config> #include <__split_buffer> #include @@ -162,7 +158,13 @@ template #include #include -#include <__undef_min_max> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD @@ -2900,4 +2902,6 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_DEQUE diff --git a/include/experimental/algorithm b/include/experimental/algorithm index b32d7ca66bd2c..3801cae4f16e9 100644 --- a/include/experimental/algorithm +++ b/include/experimental/algorithm @@ -39,17 +39,18 @@ SampleIterator sample(PopulationIterator first, PopulationIterator last, #include #include -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_LFTS +_LIBCPP_PUSH_MACROS +#include <__undef_macros> +_LIBCPP_BEGIN_NAMESPACE_LFTS + template _LIBCPP_INLINE_VISIBILITY _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) @@ -67,4 +68,6 @@ _SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last, _LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ diff --git a/include/experimental/dynarray b/include/experimental/dynarray index f96a0e5fed389..16193317ad201 100644 --- a/include/experimental/dynarray +++ b/include/experimental/dynarray @@ -107,6 +107,9 @@ public: #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + namespace std { namespace experimental { inline namespace __array_extensions_v1 { template @@ -295,5 +298,7 @@ template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : true_type {}; _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // if _LIBCPP_STD_VER > 11 #endif // _LIBCPP_DYNARRAY diff --git a/include/experimental/functional b/include/experimental/functional index 75fc8e99f3529..a136cbb57c858 100644 --- a/include/experimental/functional +++ b/include/experimental/functional @@ -89,21 +89,22 @@ inline namespace fundamentals_v1 { #include #include - #include #include #include #include #include -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_LFTS #if _LIBCPP_STD_VER > 11 @@ -456,4 +457,6 @@ make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIter _LIBCPP_END_NAMESPACE_LFTS +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/include/experimental/memory_resource b/include/experimental/memory_resource index 743f9cbe639cc..d101f3e08113e 100644 --- a/include/experimental/memory_resource +++ b/include/experimental/memory_resource @@ -82,6 +82,9 @@ namespace pmr { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR // Round __s up to next multiple of __a. @@ -419,4 +422,6 @@ using resource_adaptor = __resource_adaptor_imp< _LIBCPP_END_NAMESPACE_LFTS_PMR +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */ diff --git a/include/experimental/numeric b/include/experimental/numeric index 6488a68eca6c4..d784c08f0fe8a 100644 --- a/include/experimental/numeric +++ b/include/experimental/numeric @@ -41,6 +41,9 @@ inline namespace fundamentals_v2 { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + #if _LIBCPP_STD_VER > 11 _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 @@ -110,4 +113,7 @@ lcm(_Tp __m, _Up __n) _LIBCPP_END_NAMESPACE_LFTS_V2 #endif /* _LIBCPP_STD_VER > 11 */ + +_LIBCPP_POP_MACROS + #endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */ diff --git a/include/experimental/optional b/include/experimental/optional index 48adfbae51678..b251748fbf37f 100644 --- a/include/experimental/optional +++ b/include/experimental/optional @@ -143,6 +143,21 @@ namespace std { namespace experimental { inline namespace fundamentals_v1 { #include #include #include +#if _LIBCPP_STD_VER > 11 +#include +#include +#include +#include <__functional_base> +#include <__debug> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access @@ -160,17 +175,6 @@ _LIBCPP_END_NAMESPACE_EXPERIMENTAL #if _LIBCPP_STD_VER > 11 -#include -#include -#include -#include <__functional_base> -#include <__undef_min_max> -#include <__debug> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - _LIBCPP_BEGIN_NAMESPACE_LFTS struct in_place_t {}; @@ -913,4 +917,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 11 +_LIBCPP_POP_MACROS + #endif // _LIBCPP_EXPERIMENTAL_OPTIONAL diff --git a/include/experimental/string_view b/include/experimental/string_view index 41c0d34d3c843..da104f9a1210d 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -189,6 +189,9 @@ namespace std { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_LFTS template > @@ -810,4 +813,6 @@ quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_LFTS_STRING_VIEW diff --git a/include/forward_list b/include/forward_list index e4ab41e38b112..8bfa9a084338d 100644 --- a/include/forward_list +++ b/include/forward_list @@ -167,19 +167,20 @@ template */ #include <__config> - #include #include #include #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template struct __forward_list_node; @@ -1719,4 +1720,6 @@ swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_FORWARD_LIST diff --git a/include/fstream b/include/fstream index 5ec42bd13407b..e41a53af4a0c0 100644 --- a/include/fstream +++ b/include/fstream @@ -171,12 +171,14 @@ typedef basic_fstream wfstream; #include <__locale> #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -1476,4 +1478,6 @@ basic_fstream<_CharT, _Traits>::close() _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_FSTREAM diff --git a/include/istream b/include/istream index 530f204cfad9f..0b8e05d95bd87 100644 --- a/include/istream +++ b/include/istream @@ -162,12 +162,14 @@ template #include <__config> #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -1683,4 +1685,6 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream class numeric_limits; */ #include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #include -#include <__undef_min_max> - #if defined(_LIBCPP_COMPILER_MSVC) #include "support/win32/limits_msvc_win32.h" #endif // _LIBCPP_MSVCRT @@ -119,6 +112,14 @@ template<> class numeric_limits; #include "support/ibm/limits.h" #endif // __IBMCPP__ +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD enum float_round_style @@ -182,14 +183,14 @@ protected: static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; }; -template +template struct __libcpp_compute_min { - static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << digits); + static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits); }; -template -struct __libcpp_compute_min<_Tp, digits, false> +template +struct __libcpp_compute_min<_Tp, __digits, false> { static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0); }; @@ -811,4 +812,6 @@ template _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_LIMITS diff --git a/include/list b/include/list index 5e76d1103371d..20a66c36002df 100644 --- a/include/list +++ b/include/list @@ -177,14 +177,16 @@ template #include #include -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template struct __list_node; @@ -2415,4 +2417,6 @@ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_LIST diff --git a/include/locale b/include/locale index d29a2dc70a5b9..6aaa22ccaa15a 100644 --- a/include/locale +++ b/include/locale @@ -192,14 +192,7 @@ template class messages_byname; #endif #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include -#elif defined(_NEWLIB_VERSION) -// FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an -// include of once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html -// has had a chance to bake for a bit -#include -#endif +#include #ifdef _LIBCPP_HAS_CATOPEN #include #endif @@ -208,18 +201,20 @@ template class messages_byname; #include #endif -#include <__undef_min_max> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #ifdef _LIBCPP_LOCALE__L_EXTENSIONS #include <__bsd_locale_defaults.h> #else #include <__bsd_locale_fallbacks.h> #endif +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD #if defined(__APPLE__) || defined(__FreeBSD__) @@ -4274,4 +4269,6 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_LOCALE diff --git a/include/memory b/include/memory index 31dc73d8b1422..711551d5732d4 100644 --- a/include/memory +++ b/include/memory @@ -658,12 +658,14 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); # include #endif -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -1541,7 +1543,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {return __a.allocate(__n);} _LIBCPP_INLINE_VISIBILITY static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) - {return allocate(__a, __n, __hint, + {return __allocate(__a, __n, __hint, __has_allocate_hint());} _LIBCPP_INLINE_VISIBILITY @@ -1595,7 +1597,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits _LIBCPP_INLINE_VISIBILITY static allocator_type select_on_container_copy_construction(const allocator_type& __a) - {return select_on_container_copy_construction( + {return __select_on_container_copy_construction( __has_select_on_container_copy_construction(), __a);} @@ -1694,11 +1696,11 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits private: _LIBCPP_INLINE_VISIBILITY - static pointer allocate(allocator_type& __a, size_type __n, + static pointer __allocate(allocator_type& __a, size_type __n, const_void_pointer __hint, true_type) {return __a.allocate(__n, __hint);} _LIBCPP_INLINE_VISIBILITY - static pointer allocate(allocator_type& __a, size_type __n, + static pointer __allocate(allocator_type& __a, size_type __n, const_void_pointer, false_type) {return __a.allocate(__n);} @@ -1735,11 +1737,11 @@ private: _LIBCPP_INLINE_VISIBILITY static allocator_type - select_on_container_copy_construction(true_type, const allocator_type& __a) + __select_on_container_copy_construction(true_type, const allocator_type& __a) {return __a.select_on_container_copy_construction();} _LIBCPP_INLINE_VISIBILITY static allocator_type - select_on_container_copy_construction(false_type, const allocator_type& __a) + __select_on_container_copy_construction(false_type, const allocator_type& __a) {return __a;} }; @@ -3101,28 +3103,28 @@ struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< struct __destruct_n { private: - size_t size; + size_t __size_; template _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT - {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} + {for (size_t __i = 0; __i < __size_; ++__i, ++__p) __p->~_Tp();} template _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT - {++size;} + {++__size_;} _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT - {size = __s;} + {__size_ = __s;} _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT {} public: _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT - : size(__s) {} + : __size_(__s) {} template _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT @@ -5574,4 +5576,6 @@ struct __temp_value { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_MEMORY diff --git a/include/module.modulemap b/include/module.modulemap index 98b1870afcc18..3194b5c9f2a25 100644 --- a/include/module.modulemap +++ b/include/module.modulemap @@ -484,7 +484,7 @@ module std [system] { module __string { header "__string" export * } module __tree { header "__tree" export * } module __tuple { header "__tuple" export * } - module __undef_min_max { header "__undef_min_max" export * } + module __undef_macros { header "__undef_macros" export * } module experimental { requires cplusplus11 diff --git a/include/mutex b/include/mutex index 0b25614e8ead5..55380882044d6 100644 --- a/include/mutex +++ b/include/mutex @@ -196,12 +196,14 @@ template #endif #include <__threading_support> -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS @@ -696,4 +698,6 @@ call_once(once_flag& __flag, const _Callable& __func) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_MUTEX diff --git a/include/numeric b/include/numeric index 9c98cdbe262e9..0e53ba33c3c72 100644 --- a/include/numeric +++ b/include/numeric @@ -71,6 +71,9 @@ template #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -267,4 +270,6 @@ lcm(_Tp __m, _Up __n) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_NUMERIC diff --git a/include/optional b/include/optional index 70b6eb44dcd69..8c8ee76b1411e 100644 --- a/include/optional +++ b/include/optional @@ -146,7 +146,6 @@ namespace std { #include <__config> #include <__debug> #include <__functional_base> -#include <__undef_min_max> #include #include #include @@ -158,6 +157,10 @@ namespace std { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + namespace std // purposefully not using versioning namespace { @@ -1315,4 +1318,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 14 +_LIBCPP_POP_MACROS + #endif // _LIBCPP_OPTIONAL diff --git a/include/random b/include/random index 6c36e8c01ae22..ba8a088dfcb15 100644 --- a/include/random +++ b/include/random @@ -1646,12 +1646,14 @@ class piecewise_linear_distribution #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // __is_seed_sequence @@ -2013,41 +2015,41 @@ template class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine; -template +template bool -operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, +operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); -template +template _LIBCPP_INLINE_VISIBILITY bool -operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, +operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template + template friend bool - operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); - template + template friend bool - operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x); private: @@ -2384,13 +2386,13 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, return __z ^ __rshift<__l>(__z); } -template +template bool -operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, +operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { if (__x.__i_ == __y.__i_) @@ -2428,26 +2430,26 @@ operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, __x.__x_ + (_Np - (__y.__i_ + __j))); } -template +template inline _LIBCPP_INLINE_VISIBILITY bool -operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, +operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y) { return !(__x == __y); } template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); @@ -2463,17 +2465,17 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, } template + class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, + _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, + _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, + mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); - _UI __t[_Np]; + _UInt __t[_Np]; for (size_t __i = 0; __i < _Np; ++__i) __is >> __t[__i]; if (!__is.fail()) @@ -2501,30 +2503,30 @@ typedef mersenne_twister_engine class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine; -template +template bool operator==( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); -template +template _LIBCPP_INLINE_VISIBILITY bool operator!=( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); + subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); template class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine @@ -2586,33 +2588,33 @@ public: _LIBCPP_INLINE_VISIBILITY void discard(unsigned long long __z) {for (; __z; --__z) operator()();} - template + template friend bool operator==( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); - template + template friend bool operator!=( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); + subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); private: @@ -2711,11 +2713,11 @@ subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()() return __xr; } -template +template bool operator==( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y) + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) { if (__x.__c_ != __y.__c_) return false; @@ -2754,21 +2756,21 @@ operator==( __x.__x_ + (_Rp - (__y.__i_ + __j))); } -template +template inline _LIBCPP_INLINE_VISIBILITY bool operator!=( - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y) + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) { return !(__x == __y); } template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x) + const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__os); __os.flags(ios_base::dec | ios_base::left); @@ -2784,14 +2786,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, } template + class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x) + subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) { __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); - _UI __t[_Rp+1]; + _UInt __t[_Rp+1]; for (size_t __i = 0; __i < _Rp+1; ++__i) __is >> __t[__i]; if (!__is.fail()) @@ -2986,13 +2988,13 @@ typedef discard_block_engine ranlux48; template class _LIBCPP_TEMPLATE_VIS independent_bits_engine { - template + template class __get_n { - static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UI>::digits; + static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits; static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0); static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np; - static _LIBCPP_CONSTEXPR const _UI _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0; + static _LIBCPP_CONSTEXPR const _UInt _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0; public: static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np; }; @@ -3091,33 +3093,33 @@ public: _LIBCPP_INLINE_VISIBILITY const _Engine& base() const _NOEXCEPT {return __e_;} - template + template friend bool operator==( - const independent_bits_engine<_Eng, _Wp, _UI>& __x, - const independent_bits_engine<_Eng, _Wp, _UI>& __y); + const independent_bits_engine<_Eng, _Wp, _UInt>& __x, + const independent_bits_engine<_Eng, _Wp, _UInt>& __y); - template + template friend bool operator!=( - const independent_bits_engine<_Eng, _Wp, _UI>& __x, - const independent_bits_engine<_Eng, _Wp, _UI>& __y); + const independent_bits_engine<_Eng, _Wp, _UInt>& __x, + const independent_bits_engine<_Eng, _Wp, _UInt>& __y); template + class _Eng, size_t _Wp, class _UInt> friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const independent_bits_engine<_Eng, _Wp, _UI>& __x); + const independent_bits_engine<_Eng, _Wp, _UInt>& __x); template + class _Eng, size_t _Wp, class _UInt> friend basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - independent_bits_engine<_Eng, _Wp, _UI>& __x); + independent_bits_engine<_Eng, _Wp, _UInt>& __x); private: _LIBCPP_INLINE_VISIBILITY @@ -3179,40 +3181,40 @@ independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) return _Sp; } -template +template inline _LIBCPP_INLINE_VISIBILITY bool operator==( - const independent_bits_engine<_Eng, _Wp, _UI>& __x, - const independent_bits_engine<_Eng, _Wp, _UI>& __y) + const independent_bits_engine<_Eng, _Wp, _UInt>& __x, + const independent_bits_engine<_Eng, _Wp, _UInt>& __y) { return __x.base() == __y.base(); } -template +template inline _LIBCPP_INLINE_VISIBILITY bool operator!=( - const independent_bits_engine<_Eng, _Wp, _UI>& __x, - const independent_bits_engine<_Eng, _Wp, _UI>& __y) + const independent_bits_engine<_Eng, _Wp, _UInt>& __x, + const independent_bits_engine<_Eng, _Wp, _UInt>& __y) { return !(__x == __y); } template + class _Eng, size_t _Wp, class _UInt> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const independent_bits_engine<_Eng, _Wp, _UI>& __x) + const independent_bits_engine<_Eng, _Wp, _UInt>& __x) { return __os << __x.base(); } template + class _Eng, size_t _Wp, class _UInt> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, - independent_bits_engine<_Eng, _Wp, _UI>& __x) + independent_bits_engine<_Eng, _Wp, _UInt>& __x) { _Eng __e; __is >> __e; @@ -6736,4 +6738,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_RANDOM diff --git a/include/ratio b/include/ratio index fa893637d51d5..27aa0ded32e67 100644 --- a/include/ratio +++ b/include/ratio @@ -83,12 +83,14 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // __static_gcd @@ -520,4 +522,6 @@ template _LIBCPP_CONSTEXPR bool ratio_greater_equal_v _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_RATIO diff --git a/include/regex b/include/regex index 0f49b95a65617..443c2e3034654 100644 --- a/include/regex +++ b/include/regex @@ -765,12 +765,14 @@ typedef regex_token_iterator wsregex_token_iterator; #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD namespace regex_constants @@ -6562,4 +6564,6 @@ regex_replace(const _CharT* __s, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_REGEX diff --git a/include/shared_mutex b/include/shared_mutex index ff36ee6ac67d7..9cb81528cd9dd 100644 --- a/include/shared_mutex +++ b/include/shared_mutex @@ -125,12 +125,14 @@ template #include <__config> +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + #if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX) #include <__mutex_base> -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -500,4 +502,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 11 +_LIBCPP_POP_MACROS + #endif // _LIBCPP_SHARED_MUTEX diff --git a/include/sstream b/include/sstream index 411374207b4a2..b9903f9618235 100644 --- a/include/sstream +++ b/include/sstream @@ -175,12 +175,14 @@ typedef basic_stringstream wstringstream; #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // basic_stringbuf @@ -970,4 +972,6 @@ basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_SSTREAM diff --git a/include/stdexcept b/include/stdexcept index d501d09160852..95a96cc07678b 100644 --- a/include/stdexcept +++ b/include/stdexcept @@ -61,9 +61,9 @@ class _LIBCPP_HIDDEN __libcpp_refstring bool __uses_refcount() const; public: - explicit __libcpp_refstring(const char* msg); - __libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT; - __libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT; + explicit __libcpp_refstring(const char* __msg); + __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT; + __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT; ~__libcpp_refstring(); const char* c_str() const _NOEXCEPT {return __imp_;} diff --git a/include/stdio.h b/include/stdio.h index dc534970f9d88..f124176401648 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -110,10 +110,9 @@ void perror(const char* s); #ifdef __cplusplus // snprintf -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_MSVCRT_LIKE) 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/streambuf b/include/streambuf index 12eded5c4d316..a10ce1bf56362 100644 --- a/include/streambuf +++ b/include/streambuf @@ -116,6 +116,9 @@ protected: #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -486,4 +489,6 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios operator "" s( const char32_t *str, size_t len ); // C++1 #include #endif -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // fpos @@ -899,7 +901,7 @@ public: void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} - void reserve(size_type res_arg = 0); + void reserve(size_type __res_arg = 0); _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() _NOEXCEPT {reserve();} _LIBCPP_INLINE_VISIBILITY @@ -985,9 +987,9 @@ public: basic_string& assign(const basic_string& __str) { return *this = __str; } #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - basic_string& assign(basic_string&& str) + basic_string& assign(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) - {*this = _VSTD::move(str); return *this;} + {*this = _VSTD::move(__str); return *this;} #endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); template @@ -997,7 +999,7 @@ public: __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& >::type - assign(const _Tp & __t, size_type pos, size_type n=npos); + assign(const _Tp & __t, size_type __pos, size_type __n=npos); basic_string& assign(const value_type* __s, size_type __n); basic_string& assign(const value_type* __s); basic_string& assign(size_type __n, value_type __c); @@ -4041,4 +4043,6 @@ _LIBCPP_EXTERN_TEMPLATE(string operator+, allocator - #include <__string> #include #include @@ -178,6 +177,10 @@ namespace std { #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template > @@ -353,9 +356,9 @@ public: _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare( size_type __pos1, size_type __n1, - basic_string_view _sv, size_type __pos2, size_type __n2) const + basic_string_view __sv, size_type __pos2, size_type __n2) const { - return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2)); + return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY @@ -784,4 +787,6 @@ inline namespace literals #endif _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_STRING_VIEW diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h index 7a6c44ca90032..b2b3ac4c799bf 100644 --- a/include/support/win32/locale_win32.h +++ b/include/support/win32/locale_win32.h @@ -52,20 +52,21 @@ 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); wint_t btowc_l( int c, locale_t loc ); int wctob_l( wint_t c, locale_t loc ); -inline _LIBCPP_ALWAYS_INLINE -decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) -{ - return ___mb_cur_max_l_func(__l); -} + +decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ); // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ #define mbtowc_l _mbtowc_l #define strtoll_l _strtoi64_l #define strtoull_l _strtoui64_l -#define strtof_l _strtof_l #define strtod_l _strtod_l +#if defined(_LIBCPP_MSVCRT) +#define strtof_l _strtof_l #define strtold_l _strtold_l - +#else +float strtof_l(const char*, char**, locale_t); +long double strtold_l(const char*, char**, locale_t); +#endif inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, _locale_t loc) diff --git a/include/thread b/include/thread index 360b43d5e555a..1b8dca394aa49 100644 --- a/include/thread +++ b/include/thread @@ -105,6 +105,9 @@ void sleep_for(const chrono::duration& rel_time); #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + #define __STDCPP_THREADS__ __cplusplus #ifdef _LIBCPP_HAS_NO_THREADS @@ -476,4 +479,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS +_LIBCPP_POP_MACROS + #endif // _LIBCPP_THREAD diff --git a/include/tuple b/include/tuple index b869b861cce00..aa4713faf06fa 100644 --- a/include/tuple +++ b/include/tuple @@ -169,7 +169,7 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) template class __tuple_leaf { - _Hp value; + _Hp __value_; template static constexpr bool __can_bind_reference() { @@ -188,28 +188,28 @@ class __tuple_leaf __tuple_leaf& operator=(const __tuple_leaf&); public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() - _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value() + _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY __tuple_leaf(integral_constant, const _Alloc&) - : value() + : __value_() {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY __tuple_leaf(integral_constant, const _Alloc& __a) - : value(allocator_arg_t(), __a) + : __value_(allocator_arg_t(), __a) {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY __tuple_leaf(integral_constant, const _Alloc& __a) - : value(__a) + : __value_(__a) {static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");} @@ -223,28 +223,28 @@ public: > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) - : value(_VSTD::forward<_Tp>(__t)) + : __value_(_VSTD::forward<_Tp>(__t)) {static_assert(__can_bind_reference<_Tp>(), "Attempted to construct a reference element in a tuple with an rvalue");} template _LIBCPP_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant, const _Alloc&, _Tp&& __t) - : value(_VSTD::forward<_Tp>(__t)) + : __value_(_VSTD::forward<_Tp>(__t)) {static_assert(__can_bind_reference<_Tp>(), "Attempted to construct a reference element in a tuple with an rvalue");} template _LIBCPP_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) - : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) + : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");} template _LIBCPP_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant, const _Alloc& __a, _Tp&& __t) - : value(_VSTD::forward<_Tp>(__t), __a) + : __value_(_VSTD::forward<_Tp>(__t), __a) {static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");} @@ -256,7 +256,7 @@ public: __tuple_leaf& operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value)) { - value = _VSTD::forward<_Tp>(__t); + __value_ = _VSTD::forward<_Tp>(__t); return *this; } @@ -267,8 +267,8 @@ public: return 0; } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;} }; template @@ -473,9 +473,9 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. template class _LIBCPP_TEMPLATE_VIS tuple { - typedef __tuple_impl::type, _Tp...> base; + typedef __tuple_impl::type, _Tp...> _BaseT; - base base_; + _BaseT __base_; #if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION) static constexpr bool _EnableImplicitReducedArityExtension = true; @@ -628,7 +628,7 @@ public: >::type> _LIBCPP_INLINE_VISIBILITY tuple(_AllocArgT, _Alloc const& __a) - : base_(allocator_arg_t(), __a, + : __base_(allocator_arg_t(), __a, __tuple_indices<>(), __tuple_types<>(), typename __make_tuple_indices::type(), __tuple_types<_Tp...>()) {} @@ -644,7 +644,7 @@ public: > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(const _Tp& ... __t) _NOEXCEPT_((__all::value...>::value)) - : base_(typename __make_tuple_indices::type(), + : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), @@ -662,7 +662,7 @@ public: > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all::value...>::value)) - : base_(typename __make_tuple_indices::type(), + : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), typename __make_tuple_types::type(), @@ -680,7 +680,7 @@ public: > _LIBCPP_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) - : base_(allocator_arg_t(), __a, + : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), @@ -700,7 +700,7 @@ public: _LIBCPP_INLINE_VISIBILITY explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) - : base_(allocator_arg_t(), __a, + : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices<0>::type(), @@ -727,7 +727,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple(_Up&&... __u) _NOEXCEPT_(( - is_nothrow_constructible::type, typename __make_tuple_types::type, typename __make_tuple_indices::type, @@ -735,7 +735,7 @@ public: _Up... >::value )) - : base_(typename __make_tuple_indices::type(), + : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), @@ -760,7 +760,7 @@ public: explicit tuple(_Up&&... __u) _NOEXCEPT_(( - is_nothrow_constructible::type, typename __make_tuple_types::type, typename __make_tuple_indices::type, @@ -768,7 +768,7 @@ public: _Up... >::value )) - : base_(typename __make_tuple_indices::type(), + : __base_(typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), typename __make_tuple_types::type(), @@ -786,7 +786,7 @@ public: > _LIBCPP_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) - : base_(allocator_arg_t(), __a, + : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), @@ -806,7 +806,7 @@ public: _LIBCPP_INLINE_VISIBILITY explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) - : base_(allocator_arg_t(), __a, + : __base_(allocator_arg_t(), __a, typename __make_tuple_indices::type(), typename __make_tuple_types::type(), typename __make_tuple_indices::type(), @@ -824,8 +824,8 @@ public: >::type = false > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 - tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value)) - : base_(_VSTD::forward<_Tuple>(__t)) {} + tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value)) + : __base_(_VSTD::forward<_Tuple>(__t)) {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit - tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value)) - : base_(_VSTD::forward<_Tuple>(__t)) {} + tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value)) + : __base_(_VSTD::forward<_Tuple>(__t)) {} template _LIBCPP_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) - : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} + : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} template (__t)) {} + : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} using _CanCopyAssign = __all::value...>; using _CanMoveAssign = __all::value...>; @@ -876,7 +876,7 @@ public: tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t) _NOEXCEPT_((__all::value...>::value)) { - base_.operator=(__t.base_); + __base_.operator=(__t.__base_); return *this; } @@ -884,7 +884,7 @@ public: tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t) _NOEXCEPT_((__all::value...>::value)) { - base_.operator=(static_cast(__t.base_)); + __base_.operator=(static_cast<_BaseT&&>(__t.__base_)); return *this; } @@ -896,15 +896,15 @@ public: > _LIBCPP_INLINE_VISIBILITY tuple& - operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable::value)) + operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value)) { - base_.operator=(_VSTD::forward<_Tuple>(__t)); + __base_.operator=(_VSTD::forward<_Tuple>(__t)); return *this; } _LIBCPP_INLINE_VISIBILITY void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) - {base_.swap(__t.base_);} + {__base_.swap(__t.__base_);} }; template <> @@ -948,7 +948,7 @@ typename tuple_element<_Ip, tuple<_Tp...> >::type& get(tuple<_Tp...>& __t) _NOEXCEPT { typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; - return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get(); + return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); } template @@ -957,7 +957,7 @@ const typename tuple_element<_Ip, tuple<_Tp...> >::type& get(const tuple<_Tp...>& __t) _NOEXCEPT { typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; - return static_cast&>(__t.base_).get(); + return static_cast&>(__t.__base_).get(); } template @@ -967,7 +967,7 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT { typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast( - static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get()); + static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); } template @@ -977,7 +977,7 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT { typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; return static_cast( - static_cast&&>(__t.base_).get()); + static_cast&&>(__t.__base_).get()); } #if _LIBCPP_STD_VER > 11 diff --git a/include/valarray b/include/valarray index f8e19acdb7197..ee61238a932f3 100644 --- a/include/valarray +++ b/include/valarray @@ -347,12 +347,14 @@ template unspecified2 end(const valarray& v); #include #include -#include <__undef_min_max> - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_TEMPLATE_VIS valarray; @@ -4865,4 +4867,6 @@ end(const valarray<_Tp>& __v) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_VALARRAY diff --git a/include/vector b/include/vector index 6759dbd8a5849..ee19fb7081a2d 100644 --- a/include/vector +++ b/include/vector @@ -275,14 +275,16 @@ void swap(vector& x, vector& y) #include <__split_buffer> #include <__functional_base> -#include <__undef_min_max> - #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -3357,4 +3359,6 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_VECTOR diff --git a/include/wchar.h b/include/wchar.h index 25a318faff256..a5666e193a5ba 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -166,7 +166,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD } #endif -#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT) +#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT_LIKE) extern "C" { size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, size_t nmc, size_t len, mbstate_t *__restrict ps); diff --git a/src/chrono.cpp b/src/chrono.cpp index 9b277a610cd25..d0e184ad32fb6 100644 --- a/src/chrono.cpp +++ b/src/chrono.cpp @@ -37,7 +37,7 @@ #if defined(_LIBCPP_WIN32API) #define WIN32_LEAN_AND_MEAN #define VC_EXTRA_LEAN -#include +#include #if _WIN32_WINNT >= _WIN32_WINNT_WIN8 #include #endif diff --git a/src/condition_variable.cpp b/src/condition_variable.cpp index 3f607271b9ebf..2200aefb804d9 100644 --- a/src/condition_variable.cpp +++ b/src/condition_variable.cpp @@ -14,6 +14,7 @@ #include "condition_variable" #include "thread" #include "system_error" +#include "__undef_macros" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/src/ios.cpp b/src/ios.cpp index 7c76ca258b264..0f1d88e378f54 100644 --- a/src/ios.cpp +++ b/src/ios.cpp @@ -22,6 +22,7 @@ #include "new" #include "streambuf" #include "string" +#include "__undef_macros" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/src/locale.cpp b/src/locale.cpp index 4163c2c0af653..3d61fbede58a2 100644 --- a/src/locale.cpp +++ b/src/locale.cpp @@ -36,6 +36,7 @@ #endif #include #include +#include "__undef_macros" // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. diff --git a/src/mutex.cpp b/src/mutex.cpp index b858e8877ae5c..c36bd5549da8e 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -12,6 +12,7 @@ #include "limits" #include "system_error" #include "include/atomic_support.h" +#include "__undef_macros" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS diff --git a/src/new.cpp b/src/new.cpp index 21b30740196b0..2b2682fa66177 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -183,7 +183,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC if (static_cast(alignment) < sizeof(void*)) alignment = std::align_val_t(sizeof(void*)); void* p; -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_MSVCRT_LIKE) while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr) #else while (::posix_memalign(&p, static_cast(alignment), size) != 0) @@ -256,7 +256,7 @@ void operator delete(void* ptr, std::align_val_t) _NOEXCEPT { if (ptr) -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_MSVCRT_LIKE) ::_aligned_free(ptr); #else ::free(ptr); diff --git a/src/strstream.cpp b/src/strstream.cpp index be94f9c89e837..01523cf45462e 100644 --- a/src/strstream.cpp +++ b/src/strstream.cpp @@ -13,6 +13,7 @@ #include "cstring" #include "cstdlib" #include "__debug" +#include "__undef_macros" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp index 28cb4491781f0..13a6eaedacb23 100644 --- a/src/support/win32/locale_win32.cpp +++ b/src/support/win32/locale_win32.cpp @@ -34,6 +34,18 @@ locale_t uselocale( locale_t newloc ) // uselocale returns the old locale_t return old_locale; } + +decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) +{ +#if defined(_LIBCPP_MSVCRT) + return ___mb_cur_max_l_func(__l); +#else + __libcpp_locale_guard __current(__l); + return MB_CUR_MAX; +#endif +} + + lconv *localeconv_l( locale_t loc ) { __libcpp_locale_guard __current(loc); @@ -109,3 +121,15 @@ int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ) __libcpp_locale_guard __current(loc); return vasprintf( ret, format, ap ); } + +#if !defined(_LIBCPP_MSVCRT) +float strtof_l(const char* nptr, char** endptr, locale_t loc) { + __libcpp_locale_guard __current(loc); + return strtof(nptr, endptr); +} + +long double strtold_l(const char* nptr, char** endptr, locale_t loc) { + __libcpp_locale_guard __current(loc); + return strtold(nptr, endptr); +} +#endif diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp index e989681a6d5f2..dbd1c4c418aaa 100644 --- a/src/support/win32/support.cpp +++ b/src/support/win32/support.cpp @@ -15,17 +15,6 @@ #include // strcpy, wcsncpy #include // mbstate_t -// Some of these functions aren't standard or if they conform, the name does not. - -int asprintf(char **sptr, const char *__restrict format, ...) -{ - va_list ap; - va_start(ap, format); - int result; - result = vasprintf(sptr, format, ap); - va_end(ap); - return result; -} // Like sprintf, but when return value >= 0 it returns // a pointer to a malloc'd string in *sptr. diff --git a/src/system_error.cpp b/src/system_error.cpp index cbbbb5dcd15c4..17f2c9a5ba795 100644 --- a/src/system_error.cpp +++ b/src/system_error.cpp @@ -65,7 +65,7 @@ constexpr size_t strerror_buff_size = 1024; string do_strerror_r(int ev); -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_MSVCRT_LIKE) string do_strerror_r(int ev) { char buffer[strerror_buff_size]; if (::strerror_s(buffer, strerror_buff_size, ev) == 0) diff --git a/src/thread.cpp b/src/thread.cpp index 412a8fa0a6208..550da8ea71f31 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -34,7 +34,7 @@ #if defined(_LIBCPP_WIN32API) #include -#endif // defined(_LIBCPP_WIN32API) +#endif _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/test/libcxx/min_max_macros.sh.cpp b/test/libcxx/min_max_macros.sh.cpp new file mode 100644 index 0000000000000..bae4175b1d63a --- /dev/null +++ b/test/libcxx/min_max_macros.sh.cpp @@ -0,0 +1,298 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// Test that we can include each header in two TU's and link them together. + +// RUN: %compile -fsyntax-only + +// Prevent from generating deprecated warnings for this test. +#if defined(__DEPRECATED) +#undef __DEPRECATED +#endif + +#define TEST_MACROS() static_assert(min() == true && max() == true, "") +#define min() true +#define max() true + +// Top level headers +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +#include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +#include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +#include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +#include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +#include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); + +// experimental headers +#if __cplusplus >= 201103L +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#endif // __cplusplus >= 201103L + +// extended headers +#include +TEST_MACROS(); +#include +TEST_MACROS(); diff --git a/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp b/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp index c18822bbe8117..76d5f0d679f67 100644 --- a/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp +++ b/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp @@ -34,7 +34,7 @@ int main() { // FIXME: The below warnings may get emitted as an error, a warning, or not emitted at all // depending on the flags used to compile this test. { - // expected-warning@tuple:* 0+ {{binding reference member 'value' to a temporary value}} - // expected-error@tuple:* 0+ {{binding reference member 'value' to a temporary value}} + // expected-warning@tuple:* 0+ {{binding reference member '__value_' to a temporary value}} + // expected-error@tuple:* 0+ {{binding reference member '__value_' to a temporary value}} } } diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.pass.cpp new file mode 100644 index 0000000000000..30081fc3ada37 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.pass.cpp @@ -0,0 +1,58 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// constexpr explicit operator bool() const noexcept + +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test() { + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_convertible::value, ""); + { + constexpr C c; ((void)c); + static_assert(bool(c) == false, ""); + } + { // null case + const C c = {}; ((void)c); + ASSERT_NOEXCEPT(bool(c)); + if (c) + assert(false); + else + assert(true); + assert(c.address() == nullptr); + assert(bool(c) == false); + } + { // non-null case + char dummy = 42; + C c = C::from_address((void*)&dummy); + assert(c.address() == &dummy); + assert(bool(c) == true); + } +} + +int main() +{ + do_test>(); + do_test>(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp deleted file mode 100644 index a744f56eb811b..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// constexpr explicit operator bool() const noexcept - -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test() { - static_assert(std::is_nothrow_constructible::value, ""); - static_assert(!std::is_convertible::value, ""); - { - constexpr C c; ((void)c); - static_assert(bool(c) == false, ""); - } - { // null case - const C c = {}; ((void)c); - ASSERT_NOEXCEPT(bool(c)); - if (c) - assert(false); - else - assert(true); - assert(c.address() == nullptr); - assert(bool(c) == false); - } - { // non-null case - char dummy = 42; - C c = C::from_address((void*)&dummy); - assert(c.address() == &dummy); - assert(bool(c) == true); - } -} - -int main() -{ - do_test>(); - do_test>(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.pass.cpp new file mode 100644 index 0000000000000..278ea9d0660a0 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.pass.cpp @@ -0,0 +1,60 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// bool operator==(coroutine_handle<>, coroutine_handle<>) noexcept +// bool operator!=(coroutine_handle<>, coroutine_handle<>) noexcept + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { + const C LHS = C::from_address(reinterpret_cast(LHSVal)); + const C RHS = C::from_address(reinterpret_cast(RHSVal)); + const bool ExpectIsEqual = (LHSVal == RHSVal); + assert((LHS == RHS) == ExpectIsEqual); + assert((RHS == LHS) == ExpectIsEqual); + assert((LHS != RHS) == !ExpectIsEqual); + assert((RHS != LHS) == !ExpectIsEqual); + { + static_assert(noexcept(LHS == RHS), ""); + static_assert(noexcept(LHS != RHS), ""); + ASSERT_SAME_TYPE(decltype(LHS == RHS), bool); + ASSERT_SAME_TYPE(decltype(LHS != RHS), bool); + } +} + +int main() +{ + std::pair const TestCases[] = { + {0, 0}, + {16, 16}, + {0, 16}, + {16, 0} + }; + for (auto& TC : TestCases) { + do_test>(TC.first, TC.second); + do_test>(TC.first, TC.second); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.sh.cpp deleted file mode 100644 index 05c3f230e5cad..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/equal_comp.sh.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// bool operator==(coroutine_handle<>, coroutine_handle<>) noexcept -// bool operator!=(coroutine_handle<>, coroutine_handle<>) noexcept - -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { - const C LHS = C::from_address(reinterpret_cast(LHSVal)); - const C RHS = C::from_address(reinterpret_cast(RHSVal)); - const bool ExpectIsEqual = (LHSVal == RHSVal); - assert((LHS == RHS) == ExpectIsEqual); - assert((RHS == LHS) == ExpectIsEqual); - assert((LHS != RHS) == !ExpectIsEqual); - assert((RHS != LHS) == !ExpectIsEqual); - { - static_assert(noexcept(LHS == RHS), ""); - static_assert(noexcept(LHS != RHS), ""); - ASSERT_SAME_TYPE(decltype(LHS == RHS), bool); - ASSERT_SAME_TYPE(decltype(LHS != RHS), bool); - } -} - -int main() -{ - std::pair const TestCases[] = { - {0, 0}, - {16, 16}, - {0, 16}, - {16, 0} - }; - for (auto& TC : TestCases) { - do_test>(TC.first, TC.second); - do_test>(TC.first, TC.second); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.pass.cpp new file mode 100644 index 0000000000000..e92adf033232a --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.pass.cpp @@ -0,0 +1,69 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// bool operator<(coroutine_handle<>, coroutine_handle<>) noexcept +// bool operator>(coroutine_handle<>, coroutine_handle<>) noexcept +// bool operator>=(coroutine_handle<>, coroutine_handle<>) noexcept +// bool operator<=(coroutine_handle<>, coroutine_handle<>) noexcept + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { + const C LHS = C::from_address(reinterpret_cast(LHSVal)); + const C RHS = C::from_address(reinterpret_cast(RHSVal)); + assert((LHS < RHS) == (LHSVal < RHSVal)); + assert((RHS < LHS) == (RHSVal < LHSVal)); + assert((LHS > RHS) == (LHSVal > RHSVal)); + assert((RHS > LHS) == (RHSVal > LHSVal)); + assert((LHS <= RHS) == (LHSVal <= RHSVal)); + assert((RHS <= LHS) == (RHSVal <= LHSVal)); + assert((LHS >= RHS) == (LHSVal >= RHSVal)); + assert((RHS >= LHS) == (RHSVal >= LHSVal)); + { + static_assert(noexcept(LHS < RHS), ""); + static_assert(noexcept(LHS > RHS), ""); + static_assert(noexcept(LHS <= RHS), ""); + static_assert(noexcept(LHS >= RHS), ""); + ASSERT_SAME_TYPE(decltype(LHS < RHS), bool); + ASSERT_SAME_TYPE(decltype(LHS > RHS), bool); + ASSERT_SAME_TYPE(decltype(LHS <= RHS), bool); + ASSERT_SAME_TYPE(decltype(LHS >= RHS), bool); + } +} + +int main() +{ + std::pair const TestCases[] = { + {0, 0}, + {16, 16}, + {0, 16}, + {16, 0} + }; + for (auto& TC : TestCases) { + do_test>(TC.first, TC.second); + do_test>(TC.first, TC.second); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.sh.cpp deleted file mode 100644 index 7b3bcc394c8c6..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.compare/less_comp.sh.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// bool operator<(coroutine_handle<>, coroutine_handle<>) noexcept -// bool operator>(coroutine_handle<>, coroutine_handle<>) noexcept -// bool operator>=(coroutine_handle<>, coroutine_handle<>) noexcept -// bool operator<=(coroutine_handle<>, coroutine_handle<>) noexcept - -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { - const C LHS = C::from_address(reinterpret_cast(LHSVal)); - const C RHS = C::from_address(reinterpret_cast(RHSVal)); - assert((LHS < RHS) == (LHSVal < RHSVal)); - assert((RHS < LHS) == (RHSVal < LHSVal)); - assert((LHS > RHS) == (LHSVal > RHSVal)); - assert((RHS > LHS) == (RHSVal > LHSVal)); - assert((LHS <= RHS) == (LHSVal <= RHSVal)); - assert((RHS <= LHS) == (RHSVal <= LHSVal)); - assert((LHS >= RHS) == (LHSVal >= RHSVal)); - assert((RHS >= LHS) == (RHSVal >= LHSVal)); - { - static_assert(noexcept(LHS < RHS), ""); - static_assert(noexcept(LHS > RHS), ""); - static_assert(noexcept(LHS <= RHS), ""); - static_assert(noexcept(LHS >= RHS), ""); - ASSERT_SAME_TYPE(decltype(LHS < RHS), bool); - ASSERT_SAME_TYPE(decltype(LHS > RHS), bool); - ASSERT_SAME_TYPE(decltype(LHS <= RHS), bool); - ASSERT_SAME_TYPE(decltype(LHS >= RHS), bool); - } -} - -int main() -{ - std::pair const TestCases[] = { - {0, 0}, - {16, 16}, - {0, 16}, - {16, 0} - }; - for (auto& TC : TestCases) { - do_test>(TC.first, TC.second); - do_test>(TC.first, TC.second); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp new file mode 100644 index 0000000000000..74a9e7bda04e4 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp @@ -0,0 +1,44 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// bool done() const + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test(coro::coroutine_handle const& H) { + // FIXME Add a runtime test + { + ASSERT_SAME_TYPE(decltype(H.done()), bool); + ASSERT_NOT_NOEXCEPT(H.done()); + } +} + +int main() +{ + do_test(coro::coroutine_handle<>{}); + do_test(coro::coroutine_handle{}); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.sh.cpp deleted file mode 100644 index 48c3ca50cbf10..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.sh.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// bool done() const - -#include -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test(coro::coroutine_handle const& H) { - // FIXME Add a runtime test - { - ASSERT_SAME_TYPE(decltype(H.done()), bool); - ASSERT_NOT_NOEXCEPT(H.done()); - } -} - -int main() -{ - do_test(coro::coroutine_handle<>{}); - do_test(coro::coroutine_handle{}); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.pass.cpp new file mode 100644 index 0000000000000..0cd3d05c2de09 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.pass.cpp @@ -0,0 +1,54 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// coroutine_handle& operator=(nullptr_t) noexcept + +#include +#include +#include + +namespace coro = std::experimental; + +template +void do_test() { + int dummy = 42; + void* dummy_h = &dummy; + { + C c; ((void)c); + static_assert(std::is_nothrow_assignable::value, ""); + static_assert(!std::is_assignable::value, ""); + } + { + C c = C::from_address(dummy_h); + assert(c.address() == &dummy); + c = nullptr; + assert(c.address() == nullptr); + c = nullptr; + assert(c.address() == nullptr); + } + { + C c; + C& cr = (c = nullptr); + assert(&c == &cr); + } +} + +int main() +{ + do_test>(); + do_test>(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.sh.cpp deleted file mode 100644 index 9e7fb5b2f6873..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/assign.sh.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// coroutine_handle& operator=(nullptr_t) noexcept - -#include -#include -#include - -namespace coro = std::experimental; - -template -void do_test() { - int dummy = 42; - void* dummy_h = &dummy; - { - C c; ((void)c); - static_assert(std::is_nothrow_assignable::value, ""); - static_assert(!std::is_assignable::value, ""); - } - { - C c = C::from_address(dummy_h); - assert(c.address() == &dummy); - c = nullptr; - assert(c.address() == nullptr); - c = nullptr; - assert(c.address() == nullptr); - } - { - C c; - C& cr = (c = nullptr); - assert(&c == &cr); - } -} - -int main() -{ - do_test>(); - do_test>(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.pass.cpp new file mode 100644 index 0000000000000..be5174dd34392 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.pass.cpp @@ -0,0 +1,53 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// constexpr coroutine_handle() noexcept +// constexpr coroutine_handle(nullptr_t) noexcept + +#include +#include +#include + +namespace coro = std::experimental; + +template +void do_test() { + { + constexpr C c; + static_assert(std::is_nothrow_default_constructible::value, ""); + static_assert(c.address() == nullptr, ""); + } + { + constexpr C c(nullptr); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(c.address() == nullptr, ""); + } + { + C c; + assert(c.address() == nullptr); + } + { + C c(nullptr); + assert(c.address() == nullptr); + } +} + +int main() +{ + do_test>(); + do_test>(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.sh.cpp deleted file mode 100644 index 961253fb7ca55..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.con/construct.sh.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// constexpr coroutine_handle() noexcept -// constexpr coroutine_handle(nullptr_t) noexcept - -#include -#include -#include - -namespace coro = std::experimental; - -template -void do_test() { - { - constexpr C c; - static_assert(std::is_nothrow_default_constructible::value, ""); - static_assert(c.address() == nullptr, ""); - } - { - constexpr C c(nullptr); - static_assert(std::is_nothrow_constructible::value, ""); - static_assert(c.address() == nullptr, ""); - } - { - C c; - assert(c.address() == nullptr); - } - { - C c(nullptr); - assert(c.address() == nullptr); - } -} - -int main() -{ - do_test>(); - do_test>(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.pass.cpp new file mode 100644 index 0000000000000..aba5eb66314eb --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.pass.cpp @@ -0,0 +1,51 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// constexpr void* address() const noexcept + +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test() { + { + constexpr C c; ((void)c); + static_assert(c.address() == nullptr, ""); + } + { + const C c = {}; ((void)c); + ASSERT_NOEXCEPT(c.address()); + ASSERT_SAME_TYPE(decltype(c.address()), void*); + assert(c.address() == nullptr); + } + { + char dummy = 42; + C c = C::from_address((void*)&dummy); + assert(c.address() == &dummy); + } +} + +int main() +{ + do_test>(); + do_test>(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp deleted file mode 100644 index 7258f93905f3f..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// constexpr void* address() const noexcept - -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test() { - { - constexpr C c; ((void)c); - static_assert(c.address() == nullptr, ""); - } - { - const C c = {}; ((void)c); - ASSERT_NOEXCEPT(c.address()); - ASSERT_SAME_TYPE(decltype(c.address()), void*); - assert(c.address() == nullptr); - } - { - char dummy = 42; - C c = C::from_address((void*)&dummy); - assert(c.address() == &dummy); - } -} - -int main() -{ - do_test>(); - do_test>(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp new file mode 100644 index 0000000000000..636d5da4ec6c3 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp @@ -0,0 +1,46 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// static coroutine_handle from_address(void*) noexcept + +#include +#include +#include + +namespace coro = std::experimental; + +template +void do_test() { + { + C c = C::from_address(nullptr); + static_assert(noexcept(C::from_address(nullptr)), ""); + // FIXME: Should the return type not be 'C'? + static_assert(std::is_same::value, ""); + assert(c.address() == nullptr); + } + { + char dummy = 42; + C c = C::from_address((void*)&dummy); + assert(c.address() == &dummy); + } +} + +int main() +{ + do_test>(); + do_test>(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp deleted file mode 100644 index 26a45b033ff52..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// static coroutine_handle from_address(void*) noexcept - -#include -#include -#include - -namespace coro = std::experimental; - -template -void do_test() { - { - C c = C::from_address(nullptr); - static_assert(noexcept(C::from_address(nullptr)), ""); - // FIXME: Should the return type not be 'C'? - static_assert(std::is_same::value, ""); - assert(c.address() == nullptr); - } - { - char dummy = 42; - C c = C::from_address((void*)&dummy); - assert(c.address() == &dummy); - } -} - -int main() -{ - do_test>(); - do_test>(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp new file mode 100644 index 0000000000000..34223296231ca --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp @@ -0,0 +1,63 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// namespace std { +// template struct hash>; +// } + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { + const size_t ExpectLHS = std::hash{}(reinterpret_cast(LHSVal)); + const size_t ExpectRHS = std::hash{}(reinterpret_cast(RHSVal)); + const C LHS = C::from_address(reinterpret_cast(LHSVal)); + const C RHS = C::from_address(reinterpret_cast(RHSVal)); + const std::hash h; + // FIXME: libc++'s implementation hash's the result of LHS.address(), so we + // expect that value. However this is not required. + assert(h(LHS) == ExpectLHS); + assert(h(RHS) == ExpectRHS); + assert((h(LHS) == h(RHS)) == (LHSVal == RHSVal)); + { + ASSERT_SAME_TYPE(decltype(h(LHS)), size_t); + ASSERT_NOEXCEPT(std::hash{}(LHS)); + } +} + +int main() +{ + std::pair const TestCases[] = { + {0, 0}, + {0, 8}, + {8, 8}, + {8, 16} + }; + for (auto& TC : TestCases) { + do_test>(TC.first, TC.second); + do_test>(TC.first, TC.second); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.sh.cpp deleted file mode 100644 index 5f66b3e113140..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.sh.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// namespace std { -// template struct hash>; -// } - -#include -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test(uintptr_t LHSVal, uintptr_t RHSVal) { - const size_t ExpectLHS = std::hash{}(reinterpret_cast(LHSVal)); - const size_t ExpectRHS = std::hash{}(reinterpret_cast(RHSVal)); - const C LHS = C::from_address(reinterpret_cast(LHSVal)); - const C RHS = C::from_address(reinterpret_cast(RHSVal)); - const std::hash h; - // FIXME: libc++'s implementation hash's the result of LHS.address(), so we - // expect that value. However this is not required. - assert(h(LHS) == ExpectLHS); - assert(h(RHS) == ExpectRHS); - assert((h(LHS) == h(RHS)) == (LHSVal == RHSVal)); - { - ASSERT_SAME_TYPE(decltype(h(LHS)), size_t); - ASSERT_NOEXCEPT(std::hash{}(LHS)); - } -} - -int main() -{ - std::pair const TestCases[] = { - {0, 0}, - {0, 8}, - {8, 8}, - {8, 16} - }; - for (auto& TC : TestCases) { - do_test>(TC.first, TC.second); - do_test>(TC.first, TC.second); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp new file mode 100644 index 0000000000000..4a61047a830aa --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp @@ -0,0 +1,49 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// Promise& promise() const + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +void do_test(coro::coroutine_handle&& H) { + + // FIXME Add a runtime test + { + ASSERT_SAME_TYPE(decltype(H.promise()), Promise&); + LIBCPP_ASSERT_NOT_NOEXCEPT(H.promise()); + } + { + auto const& CH = H; + ASSERT_SAME_TYPE(decltype(CH.promise()), Promise&); + LIBCPP_ASSERT_NOT_NOEXCEPT(CH.promise()); + } +} + +int main() +{ + do_test(coro::coroutine_handle{}); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp deleted file mode 100644 index b38d7871be4b0..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// Promise& promise() const - -#include -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -void do_test(coro::coroutine_handle&& H) { - - // FIXME Add a runtime test - { - ASSERT_SAME_TYPE(decltype(H.promise()), Promise&); - LIBCPP_ASSERT_NOT_NOEXCEPT(H.promise()); - } - { - auto const& CH = H; - ASSERT_SAME_TYPE(decltype(CH.promise()), Promise&); - LIBCPP_ASSERT_NOT_NOEXCEPT(CH.promise()); - } -} - -int main() -{ - do_test(coro::coroutine_handle{}); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.pass.cpp new file mode 100644 index 0000000000000..df3337c4cc01c --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.pass.cpp @@ -0,0 +1,61 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// void destroy() + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +template +auto has_destroy_imp(H&& h, int) -> decltype(h.destroy(), std::true_type{}); +template +auto has_destroy_imp(H&&, long) -> std::false_type; + +template +constexpr bool has_destroy() { + return decltype(has_destroy_imp(std::declval(), 0))::value; +} + +template +void do_test(coro::coroutine_handle&& H) { + using HType = coro::coroutine_handle; + // FIXME Add a runtime test + { + ASSERT_SAME_TYPE(decltype(H.destroy()), void); + LIBCPP_ASSERT_NOT_NOEXCEPT(H.destroy()); + static_assert(has_destroy(), ""); + static_assert(has_destroy(), ""); + } + { + static_assert(!has_destroy(), ""); + static_assert(!has_destroy(), ""); + } +} + +int main() +{ + do_test(coro::coroutine_handle<>{}); + do_test(coro::coroutine_handle{}); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp deleted file mode 100644 index 9cc0d1d72bf7a..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// void destroy() - -#include -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -template -auto has_destroy_imp(H&& h, int) -> decltype(h.destroy(), std::true_type{}); -template -auto has_destroy_imp(H&&, long) -> std::false_type; - -template -constexpr bool has_destroy() { - return decltype(has_destroy_imp(std::declval(), 0))::value; -} - -template -void do_test(coro::coroutine_handle&& H) { - using HType = coro::coroutine_handle; - // FIXME Add a runtime test - { - ASSERT_SAME_TYPE(decltype(H.destroy()), void); - LIBCPP_ASSERT_NOT_NOEXCEPT(H.destroy()); - static_assert(has_destroy(), ""); - static_assert(has_destroy(), ""); - } - { - static_assert(!has_destroy(), ""); - static_assert(!has_destroy(), ""); - } -} - -int main() -{ - do_test(coro::coroutine_handle<>{}); - do_test(coro::coroutine_handle{}); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.pass.cpp new file mode 100644 index 0000000000000..21c05e2be9a40 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.pass.cpp @@ -0,0 +1,80 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// struct coroutine_handle; + +// void operator()() +// void resume() + +#include +#include +#include +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + + +template +auto has_resume_imp(H&& h, int) -> decltype(h.resume(), std::true_type{}); +template +auto has_resume_imp(H&&, long) -> std::false_type; + +template +constexpr bool has_resume() { + return decltype(has_resume_imp(std::declval(), 0))::value; +} + + +template +auto has_call_operator_imp(H&& h, int) -> decltype(h(), std::true_type{}); +template +auto has_call_operator_imp(H&&, long) -> std::false_type; + +template +constexpr bool has_call_operator() { + return decltype(has_call_operator_imp(std::declval(), 0))::value; +} + +template +void do_test(coro::coroutine_handle&& H) { + using HType = coro::coroutine_handle; + // FIXME Add a runtime test + { + ASSERT_SAME_TYPE(decltype(H.resume()), void); + ASSERT_SAME_TYPE(decltype(H()), void); + LIBCPP_ASSERT_NOT_NOEXCEPT(H.resume()); + LIBCPP_ASSERT_NOT_NOEXCEPT(H()); + static_assert(has_resume(), ""); + static_assert(has_resume(), ""); + static_assert(has_call_operator(), ""); + static_assert(has_call_operator(), ""); + } + { + static_assert(!has_resume(), ""); + static_assert(!has_resume(), ""); + static_assert(!has_call_operator(), ""); + static_assert(!has_call_operator(), ""); + } +} + +int main() +{ + do_test(coro::coroutine_handle<>{}); + do_test(coro::coroutine_handle{}); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp deleted file mode 100644 index b5ff187a49ce7..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// template -// struct coroutine_handle; - -// void operator()() -// void resume() - -#include -#include -#include -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - - -template -auto has_resume_imp(H&& h, int) -> decltype(h.resume(), std::true_type{}); -template -auto has_resume_imp(H&&, long) -> std::false_type; - -template -constexpr bool has_resume() { - return decltype(has_resume_imp(std::declval(), 0))::value; -} - - -template -auto has_call_operator_imp(H&& h, int) -> decltype(h(), std::true_type{}); -template -auto has_call_operator_imp(H&&, long) -> std::false_type; - -template -constexpr bool has_call_operator() { - return decltype(has_call_operator_imp(std::declval(), 0))::value; -} - -template -void do_test(coro::coroutine_handle&& H) { - using HType = coro::coroutine_handle; - // FIXME Add a runtime test - { - ASSERT_SAME_TYPE(decltype(H.resume()), void); - ASSERT_SAME_TYPE(decltype(H()), void); - LIBCPP_ASSERT_NOT_NOEXCEPT(H.resume()); - LIBCPP_ASSERT_NOT_NOEXCEPT(H()); - static_assert(has_resume(), ""); - static_assert(has_resume(), ""); - static_assert(has_call_operator(), ""); - static_assert(has_call_operator(), ""); - } - { - static_assert(!has_resume(), ""); - static_assert(!has_resume(), ""); - static_assert(!has_call_operator(), ""); - static_assert(!has_call_operator(), ""); - } -} - -int main() -{ - do_test(coro::coroutine_handle<>{}); - do_test(coro::coroutine_handle{}); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.pass.cpp new file mode 100644 index 0000000000000..844d34cc4896a --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.pass.cpp @@ -0,0 +1,51 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include + +namespace coro = std::experimental; + +struct A { + using promise_type = A*; +}; + +struct B {}; +struct C {}; + +namespace std { namespace experimental { + template <> + struct coroutine_traits<::A, int> { + using promise_type = int*; + }; + template + struct coroutine_traits<::B, Args...> { + using promise_type = B*; + }; + template <> + struct coroutine_traits<::C> { + using promise_type = void; + }; +}} + +template +void check_type() { + using P = typename coro::coroutine_traits::promise_type ; + static_assert(std::is_same::value, ""); +}; + +int main() +{ + check_type(); + check_type(); + check_type(); + check_type(); +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.sh.cpp deleted file mode 100644 index 945304a4673dd..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.handle/void_handle.sh.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include - -namespace coro = std::experimental; - -struct A { - using promise_type = A*; -}; - -struct B {}; -struct C {}; - -namespace std { namespace experimental { - template <> - struct coroutine_traits<::A, int> { - using promise_type = int*; - }; - template - struct coroutine_traits<::B, Args...> { - using promise_type = B*; - }; - template <> - struct coroutine_traits<::C> { - using promise_type = void; - }; -}} - -template -void check_type() { - using P = typename coro::coroutine_traits::promise_type ; - static_assert(std::is_same::value, ""); -}; - -int main() -{ - check_type(); - check_type(); - check_type(); - check_type(); -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.pass.cpp new file mode 100644 index 0000000000000..e26f333aa4074 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.pass.cpp @@ -0,0 +1,77 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include + +namespace coro = std::experimental; + +template +constexpr bool has_promise_type(int) { return true; } +template +constexpr bool has_promise_type(long) { return false; } +template +constexpr bool has_promise_type() { return has_promise_type(0); } + +struct A { + using promise_type = A*; +}; + +struct B {}; +struct C {}; +struct D { +private: + using promise_type = void; +}; +struct E {}; + +namespace std { namespace experimental { + template <> + struct coroutine_traits<::A, int> { + using promise_type = int*; + }; + template + struct coroutine_traits<::B, Args...> { + using promise_type = B*; + }; + template <> + struct coroutine_traits<::C> { + using promise_type = void; + }; +}} + +template +void check_type() { + using Traits = coro::coroutine_traits; + static_assert(has_promise_type(), ""); + static_assert(std::is_same::value, ""); +} + +template +void check_no_type() { + using Traits = coro::coroutine_traits; + static_assert(!has_promise_type(), ""); +} + +int main() +{ + { + check_type(); + check_type(); + check_type(); + check_type(); + } + { + check_no_type(); + check_no_type(); + check_no_type(); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.sh.cpp deleted file mode 100644 index c1d3b818d4031..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.traits/promise_type.sh.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include - -namespace coro = std::experimental; - -template -constexpr bool has_promise_type(int) { return true; } -template -constexpr bool has_promise_type(long) { return false; } -template -constexpr bool has_promise_type() { return has_promise_type(0); } - -struct A { - using promise_type = A*; -}; - -struct B {}; -struct C {}; -struct D { -private: - using promise_type = void; -}; -struct E {}; - -namespace std { namespace experimental { - template <> - struct coroutine_traits<::A, int> { - using promise_type = int*; - }; - template - struct coroutine_traits<::B, Args...> { - using promise_type = B*; - }; - template <> - struct coroutine_traits<::C> { - using promise_type = void; - }; -}} - -template -void check_type() { - using Traits = coro::coroutine_traits; - static_assert(has_promise_type(), ""); - static_assert(std::is_same::value, ""); -} - -template -void check_no_type() { - using Traits = coro::coroutine_traits; - static_assert(!has_promise_type(), ""); -} - -int main() -{ - { - check_type(); - check_type(); - check_type(); - check_type(); - } - { - check_no_type(); - check_no_type(); - check_no_type(); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.pass.cpp new file mode 100644 index 0000000000000..b10e72082c7a3 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.pass.cpp @@ -0,0 +1,73 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +using SuspendT = std::experimental::coroutines_v1::suspend_always; + +TEST_SAFE_STATIC SuspendT safe_sa; +constexpr SuspendT constexpr_sa; + +constexpr bool check_suspend_constexpr() { + SuspendT s{}; + const SuspendT scopy(s); ((void)scopy); + SuspendT smove(std::move(s)); ((void)smove); + s = scopy; + s = std::move(smove); + return true; +} + +int main() +{ + using H = coro::coroutine_handle<>; + using S = SuspendT; + H h{}; + S s{}; + S const& cs = s; + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_ready()), ""); + static_assert(std::is_same::value, ""); + assert(s.await_ready() == false); + assert(cs.await_ready() == false); + } + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_suspend(h)), ""); + static_assert(std::is_same::value, ""); + s.await_suspend(h); + cs.await_suspend(h); + } + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_resume()), ""); + static_assert(std::is_same::value, ""); + s.await_resume(); + cs.await_resume(); + } + { + static_assert(std::is_nothrow_default_constructible::value, ""); + static_assert(std::is_nothrow_copy_constructible::value, ""); + static_assert(std::is_nothrow_move_constructible::value, ""); + static_assert(std::is_nothrow_copy_assignable::value, ""); + static_assert(std::is_nothrow_move_assignable::value, ""); + static_assert(std::is_trivially_copyable::value, ""); + static_assert(check_suspend_constexpr(), ""); + } + { + // suppress unused warnings for the global constexpr test variable + ((void)constexpr_sa); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.sh.cpp deleted file mode 100644 index 1987f68e70ab4..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_always.sh.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -using SuspendT = std::experimental::coroutines_v1::suspend_always; - -TEST_SAFE_STATIC SuspendT safe_sa; -constexpr SuspendT constexpr_sa; - -constexpr bool check_suspend_constexpr() { - SuspendT s{}; - const SuspendT scopy(s); ((void)scopy); - SuspendT smove(std::move(s)); ((void)smove); - s = scopy; - s = std::move(smove); - return true; -} - -int main() -{ - using H = coro::coroutine_handle<>; - using S = SuspendT; - H h{}; - S s{}; - S const& cs = s; - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_ready()), ""); - static_assert(std::is_same::value, ""); - assert(s.await_ready() == false); - assert(cs.await_ready() == false); - } - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_suspend(h)), ""); - static_assert(std::is_same::value, ""); - s.await_suspend(h); - cs.await_suspend(h); - } - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_resume()), ""); - static_assert(std::is_same::value, ""); - s.await_resume(); - cs.await_resume(); - } - { - static_assert(std::is_nothrow_default_constructible::value, ""); - static_assert(std::is_nothrow_copy_constructible::value, ""); - static_assert(std::is_nothrow_move_constructible::value, ""); - static_assert(std::is_nothrow_copy_assignable::value, ""); - static_assert(std::is_nothrow_move_assignable::value, ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(check_suspend_constexpr(), ""); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.pass.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.pass.cpp new file mode 100644 index 0000000000000..9c2f392381f2f --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.pass.cpp @@ -0,0 +1,75 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include +#include + +#include "test_macros.h" + +namespace coro = std::experimental; + +// Test that the type is in the correct namespace +using SuspendT = std::experimental::coroutines_v1::suspend_never; + +TEST_SAFE_STATIC SuspendT safe_sn; +constexpr SuspendT constexpr_sn; + +constexpr bool check_suspend_constexpr() { + SuspendT s{}; + const SuspendT scopy(s); ((void)scopy); + SuspendT smove(std::move(s)); ((void)smove); + s = scopy; + s = std::move(smove); + return true; +} + + +int main() +{ + using H = coro::coroutine_handle<>; + using S = SuspendT; + H h{}; + S s{}; + S const& cs = s; + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_ready()), ""); + static_assert(std::is_same::value, ""); + assert(s.await_ready() == true); + assert(cs.await_ready() == true); + } + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_suspend(h)), ""); + static_assert(std::is_same::value, ""); + s.await_suspend(h); + cs.await_suspend(h); + } + { + LIBCPP_STATIC_ASSERT(noexcept(s.await_resume()), ""); + static_assert(std::is_same::value, ""); + s.await_resume(); + cs.await_resume(); + } + { + static_assert(std::is_nothrow_default_constructible::value, ""); + static_assert(std::is_nothrow_copy_constructible::value, ""); + static_assert(std::is_nothrow_move_constructible::value, ""); + static_assert(std::is_nothrow_copy_assignable::value, ""); + static_assert(std::is_nothrow_move_assignable::value, ""); + static_assert(std::is_trivially_copyable::value, ""); + static_assert(check_suspend_constexpr(), ""); + } + { + // suppress unused warnings for the global constexpr test variable + ((void)constexpr_sn); + } +} diff --git a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.sh.cpp b/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.sh.cpp deleted file mode 100644 index 72e0ac0245587..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/coroutine.trivial.awaitables/suspend_never.sh.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include -#include - -#include "test_macros.h" - -namespace coro = std::experimental; - -// Test that the type is in the correct namespace -using SuspendT = std::experimental::coroutines_v1::suspend_never; - -TEST_SAFE_STATIC SuspendT safe_sn; -constexpr SuspendT constexpr_sn; - -constexpr bool check_suspend_constexpr() { - SuspendT s{}; - const SuspendT scopy(s); ((void)scopy); - SuspendT smove(std::move(s)); ((void)smove); - s = scopy; - s = std::move(smove); - return true; -} - - -int main() -{ - using H = coro::coroutine_handle<>; - using S = SuspendT; - H h{}; - S s{}; - S const& cs = s; - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_ready()), ""); - static_assert(std::is_same::value, ""); - assert(s.await_ready() == true); - assert(cs.await_ready() == true); - } - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_suspend(h)), ""); - static_assert(std::is_same::value, ""); - s.await_suspend(h); - cs.await_suspend(h); - } - { - LIBCPP_STATIC_ASSERT(noexcept(s.await_resume()), ""); - static_assert(std::is_same::value, ""); - s.await_resume(); - cs.await_resume(); - } - { - static_assert(std::is_nothrow_default_constructible::value, ""); - static_assert(std::is_nothrow_copy_constructible::value, ""); - static_assert(std::is_nothrow_move_constructible::value, ""); - static_assert(std::is_nothrow_copy_assignable::value, ""); - static_assert(std::is_nothrow_move_assignable::value, ""); - static_assert(std::is_trivially_copyable::value, ""); - static_assert(check_suspend_constexpr(), ""); - } -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp new file mode 100644 index 0000000000000..769a825df0010 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp @@ -0,0 +1,69 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +using namespace std::experimental; + +struct coro_t { + struct promise_type { + coro_t get_return_object() { + coroutine_handle{}; + return {}; + } + suspend_never initial_suspend() { return {}; } + suspend_never final_suspend() { return {}; } + void return_void(){} + static void unhandled_exception() {} + }; +}; + +struct B { + ~B() {} + bool await_ready() { return true; } + B await_resume() { return {}; } + template void await_suspend(F) {} +}; + + +struct A { + ~A(){} + bool await_ready() { return true; } + int await_resume() { return 42; } + template void await_suspend(F) {} +}; + +int last_value = -1; +void set_value(int x) { + last_value = x; +} + +coro_t f(int n) { + if (n == 0) { + set_value(0); + co_return; + } + int val = co_await A{}; + ((void)val); + set_value(42); +} + +coro_t g() { B val = co_await B{}; } + +int main() { + last_value = -1; + f(0); + assert(last_value == 0); + f(1); + assert(last_value == 42); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.sh.cpp deleted file mode 100644 index cca875d1a6ba5..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.sh.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include - -using namespace std::experimental; - -struct coro_t { - struct promise_type { - coro_t get_return_object() { - coroutine_handle{}; - return {}; - } - suspend_never initial_suspend() { return {}; } - suspend_never final_suspend() { return {}; } - void return_void(){} - static void unhandled_exception() {} - }; -}; - -struct B { - ~B() {} - bool await_ready() { return true; } - B await_resume() { return {}; } - template void await_suspend(F) {} -}; - - -struct A { - ~A(){} - bool await_ready() { return true; } - int await_resume() { return 42; } - template void await_suspend(F) {} -}; - -int last_value = -1; -void set_value(int x) { - last_value = x; -} - -coro_t f(int n) { - if (n == 0) { - set_value(0); - co_return; - } - int val = co_await A{}; - set_value(42); -} - -coro_t g() { B val = co_await B{}; } - -int main() { - last_value = -1; - f(0); - assert(last_value == 0); - f(1); - assert(last_value == 42); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp new file mode 100644 index 0000000000000..9c3becffc0ac2 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp @@ -0,0 +1,66 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +using namespace std::experimental; + +struct coro_t { + struct promise_type { + coro_t get_return_object() { + return coroutine_handle::from_promise(*this); + } + suspend_never initial_suspend() { return {}; } + suspend_never final_suspend() { return {}; } + void return_void(){} + void unhandled_exception() {} + }; + coro_t(coroutine_handle hh) : h(hh) {} + coroutine_handle h; +}; + +struct NoSuspend { + bool await_ready() { return false; } + void await_resume() {} + template bool await_suspend(F) { return false; } +}; + +struct DoSuspend { + bool await_ready() { return false; } + void await_resume() {} + template bool await_suspend(F) { return true; } +}; + +bool f_started, f_resumed = false; +coro_t f() { + f_started = true; + co_await DoSuspend{}; + f_resumed = true; +} + +bool g_started, g_resumed = false; +coro_t g() { + g_started = true; + co_await NoSuspend{}; + g_resumed = true; +} + +int main() { + assert(!f_started && !f_resumed && !g_started && !g_resumed); + auto fret = f(); + assert(f_started && !f_resumed); + fret.h.destroy(); + assert(f_started && !f_resumed); + g(); + assert(g_started && g_resumed); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.sh.cpp deleted file mode 100644 index e51ac67f0fefb..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.sh.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// FIXME: When run under UBSAN this test hits an assertion inside Clang -// XFAIL: ubsan - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include - -using namespace std::experimental; - -struct coro_t { - struct promise_type { - coro_t get_return_object() { - return coroutine_handle::from_promise(*this); - } - suspend_never initial_suspend() { return {}; } - suspend_never final_suspend() { return {}; } - void return_void(){} - void unhandled_exception() {} - }; - coro_t(coroutine_handle hh) : h(hh) {} - coroutine_handle h; -}; - -struct NoSuspend { - bool await_ready() { return false; } - void await_resume() {} - template bool await_suspend(F) { return false; } -}; - -struct DoSuspend { - bool await_ready() { return false; } - void await_resume() {} - template bool await_suspend(F) { return true; } -}; - -bool f_started, f_resumed = false; -coro_t f() { - f_started = true; - co_await DoSuspend{}; - f_resumed = true; -} - -bool g_started, g_resumed = false; -coro_t g() { - g_started = true; - co_await NoSuspend{}; - g_resumed = true; -} - -int main() { - assert(!f_started && !f_resumed && !g_started && !g_resumed); - auto fret = f(); - assert(f_started && !f_resumed); - fret.h.destroy(); - assert(f_started && !f_resumed); - g(); - assert(g_started && g_resumed); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/expected.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/expected.pass.cpp new file mode 100644 index 0000000000000..77070cc5a3b0f --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/expected.pass.cpp @@ -0,0 +1,89 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include +using namespace std::experimental; + +struct error {}; + +template +struct expected { + + struct Data { + T val; + Error error; + }; + Data data; + + struct DataPtr { + Data *p; + ~DataPtr() { delete p; } + }; + + expected() {} + expected(T val) : data{std::move(val),{}} {} + expected(struct error, Error error) : data{{}, std::move(error)} {} + expected(DataPtr & p) : data{std::move(p.p->val), std::move(p.p->error)} {} + + struct promise_type { + Data* data; + DataPtr get_return_object() { data = new Data{}; return {data}; } + suspend_never initial_suspend() { return {}; } + suspend_never final_suspend() { return {}; } + void return_value(T v) { data->val = std::move(v); data->error = {};} + void unhandled_exception() {} + }; + + bool await_ready() { return !data.error; } + T await_resume() { return std::move(data.val); } + void await_suspend(coroutine_handle h) { + h.promise().data->error =std::move(data.error); + h.destroy(); + } + + T const& value() { return data.val; } + Error const& error() { return data.error; } +}; + +expected g() { return {0}; } +expected h() { return {error{}, 42}; } + +extern "C" void print(int); + +bool f1_started, f1_resumed = false; +expected f1() { + f1_started = true; + (void)(co_await g()); + f1_resumed = true; + co_return 100; +} + +bool f2_started, f2_resumed = false; +expected f2() { + f2_started = true; + (void)(co_await h()); + f2_resumed = true; + co_return 200; +} + +int main() { + auto c1 = f1(); + assert(f1_started && f1_resumed); + assert(c1.value() == 100); + assert(c1.error() == 0); + + auto c2 = f2(); + assert(f2_started && !f2_resumed); + assert(c2.value() == 0); + assert(c2.error() == 42); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/expected.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/expected.sh.cpp deleted file mode 100644 index b6832b0c18866..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/expected.sh.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include -using namespace std::experimental; - -struct error {}; - -template -struct expected { - - struct Data { - T val; - Error error; - }; - Data data; - - struct DataPtr { - Data *p; - ~DataPtr() { delete p; } - }; - - expected() {} - expected(T val) : data{std::move(val),{}} {} - expected(struct error, Error error) : data{{}, std::move(error)} {} - expected(DataPtr & p) : data{std::move(p.p->val), std::move(p.p->error)} {} - - struct promise_type { - Data* data; - DataPtr get_return_object() { data = new Data{}; return {data}; } - suspend_never initial_suspend() { return {}; } - suspend_never final_suspend() { return {}; } - void return_value(T v) { data->val = std::move(v); data->error = {};} - void unhandled_exception() {} - }; - - bool await_ready() { return !data.error; } - T await_resume() { return std::move(data.val); } - void await_suspend(coroutine_handle h) { - h.promise().data->error =std::move(data.error); - h.destroy(); - } - - T const& value() { return data.val; } - Error const& error() { return data.error; } -}; - -expected g() { return {0}; } -expected h() { return {error{}, 42}; } - -extern "C" void print(int); - -bool f1_started, f1_resumed = false; -expected f1() { - f1_started = true; - (void)(co_await g()); - f1_resumed = true; - co_return 100; -} - -bool f2_started, f2_resumed = false; -expected f2() { - f2_started = true; - (void)(co_await h()); - f2_resumed = true; - co_return 200; -} - -int main() { - auto c1 = f1(); - assert(f1_started && f1_resumed); - assert(c1.value() == 100); - assert(c1.error() == 0); - - auto c2 = f2(); - assert(f2_started && !f2_resumed); - assert(c2.value() == 0); - assert(c2.error() == 42); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.pass.cpp new file mode 100644 index 0000000000000..20bcf60fbf008 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.pass.cpp @@ -0,0 +1,117 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +#include "test_macros.h" + +using namespace std::experimental; + +int alive = 0; +int ctor_called = 0; +int dtor_called = 0; +void reset() { + assert(alive == 0); + alive = 0; + ctor_called = 0; + dtor_called = 0; +} +struct Noisy { + Noisy() { ++alive; ++ctor_called; } + ~Noisy() { --alive; ++dtor_called; } +#if TEST_STD_VER > 14 + Noisy(Noisy const&) = delete; +#else + // FIXME: This test depends on copy elision taking place in C++14 + // (pre-c++17 guaranteed copy elision) + Noisy(Noisy const&); +#endif +}; + +struct Bug { + bool await_ready() { return true; } + void await_suspend(std::experimental::coroutine_handle<>) {} + Noisy await_resume() { return {}; } +}; +struct coro2 { + struct promise_type { + suspend_never initial_suspend() { return{}; } + suspend_never final_suspend() { return{}; } + coro2 get_return_object() { return{}; } + void return_void() {} + Bug yield_value(int) { return {}; } + void unhandled_exception() {} + }; +}; + +// Checks that destructors are correctly invoked for the object returned by +// coawait. +coro2 a() { + reset(); + { + auto x = co_await Bug{}; + assert(alive == 1); + assert(ctor_called == 1); + assert(dtor_called == 0); + ((void)x); + } + assert(alive == 0); + assert(dtor_called == 1); +} + +coro2 b() { + reset(); + { + (void)(co_await Bug{}); + assert(ctor_called == 1); + assert(dtor_called == 1); + assert(alive == 0); + } + assert(ctor_called == 1); + assert(dtor_called == 1); + assert(alive == 0); + +} + +coro2 c() { + reset(); + { + auto x = co_yield 42; + assert(alive == 1); + assert(ctor_called == 1); + assert(dtor_called == 0); + } + assert(alive == 0); + assert(ctor_called == 1); + assert(dtor_called == 1); +} + +coro2 d() { + reset(); + { + (void)(co_yield 42); + assert(ctor_called == 1); + assert(dtor_called == 1); + assert(alive == 0); + } + assert(alive == 0); + assert(ctor_called == 1); + assert(dtor_called == 1); +} + +int main() { + a(); + b(); + c(); + d(); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.sh.cpp deleted file mode 100644 index c7e34fe919e13..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/fullexpr-dtor.sh.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include - -#include "test_macros.h" - -using namespace std::experimental; - -int alive = 0; -int ctor_called = 0; -int dtor_called = 0; -void reset() { - assert(alive == 0); - alive = 0; - ctor_called = 0; - dtor_called = 0; -} -struct Noisy { - Noisy() { ++alive; ++ctor_called; } - ~Noisy() { --alive; ++dtor_called; } -#if TEST_STD_VER > 14 - Noisy(Noisy const&) = delete; -#else - // FIXME: This test depends on copy elision taking place in C++14 - // (pre-c++17 guaranteed copy elision) - Noisy(Noisy const&); -#endif -}; - -struct Bug { - bool await_ready() { return true; } - void await_suspend(std::experimental::coroutine_handle<>) {} - Noisy await_resume() { return {}; } -}; -struct coro2 { - struct promise_type { - suspend_never initial_suspend() { return{}; } - suspend_never final_suspend() { return{}; } - coro2 get_return_object() { return{}; } - void return_void() {} - Bug yield_value(int) { return {}; } - void unhandled_exception() {} - }; -}; - -// Checks that destructors are correctly invoked for the object returned by -// coawait. -coro2 a() { - reset(); - { - auto x = co_await Bug{}; - assert(alive == 1); - assert(ctor_called == 1); - assert(dtor_called == 0); - } - assert(alive == 0); - assert(dtor_called == 1); -} - -coro2 b() { - reset(); - { - co_await Bug{}; - assert(ctor_called == 1); - assert(dtor_called == 1); - assert(alive == 0); - } - assert(ctor_called == 1); - assert(dtor_called == 1); - assert(alive == 0); - -} - -coro2 c() { - reset(); - { - auto x = co_yield 42; - assert(alive == 1); - assert(ctor_called == 1); - assert(dtor_called == 0); - } - assert(alive == 0); - assert(ctor_called == 1); - assert(dtor_called == 1); -} - -coro2 d() { - reset(); - { - co_yield 42; - assert(ctor_called == 1); - assert(dtor_called == 1); - assert(alive == 0); - } - assert(alive == 0); - assert(ctor_called == 1); - assert(dtor_called == 1); -} - -int main() { - a(); - b(); - c(); - d(); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp new file mode 100644 index 0000000000000..9200fae915760 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp @@ -0,0 +1,100 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include +#include + +#include "coroutine_types.h" + +using namespace std::experimental; + +struct minig { + struct promise_type { + int current_value; + suspend_always yield_value(int value) { + this->current_value = value; + return {}; + } + suspend_always initial_suspend() { return {}; } + suspend_always final_suspend() { return {}; } + minig get_return_object() { return minig{this}; }; + void return_void() {} + void unhandled_exception() {} + }; + + bool move_next() { + p.resume(); + return !p.done(); + } + int current_value() { return p.promise().current_value; } + + minig(minig &&rhs) : p(rhs.p) { rhs.p = nullptr; } + + ~minig() { + if (p) + p.destroy(); + } + +private: + explicit minig(promise_type *p) + : p(coroutine_handle::from_promise(*p)) {} + + coroutine_handle p; +}; + + +minig mini_count(int n) { + for (int i = 0; i < n; i++) { + co_yield i; + } +} + +generator count(int n) { + for (int i = 0; i < n; ++i) + co_yield i; +} + +generator range(int from, int n) { + for (int i = from; i < n; ++i) + co_yield i; +} + +void test_count() { + const std::vector expect = {0, 1, 2, 3, 4}; + std::vector got; + for (auto x : count(5)) + got.push_back(x); + assert(expect == got); +} + +void test_range() { + int sum = 0; + for (auto v: range(1, 20)) + sum += v; + assert(sum == 190); +} + +void test_mini_generator() { + int sum = 0; + auto g = mini_count(5); + while (g.move_next()) { + sum += g.current_value(); + } + assert(sum == 10); +} + +int main() { + test_count(); + test_range(); + test_mini_generator(); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/generator.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/generator.sh.cpp deleted file mode 100644 index 4681793ed814f..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/generator.sh.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// FIXME: When run under UBSAN this test hits an assertion inside Clang -// XFAIL: ubsan - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include -#include - -#include "coroutine_types.h" - -using namespace std::experimental; - -struct minig { - struct promise_type { - int current_value; - suspend_always yield_value(int value) { - this->current_value = value; - return {}; - } - suspend_always initial_suspend() { return {}; } - suspend_always final_suspend() { return {}; } - minig get_return_object() { return minig{this}; }; - void return_void() {} - void unhandled_exception() {} - }; - - bool move_next() { - p.resume(); - return !p.done(); - } - int current_value() { return p.promise().current_value; } - - minig(minig &&rhs) : p(rhs.p) { rhs.p = nullptr; } - - ~minig() { - if (p) - p.destroy(); - } - -private: - explicit minig(promise_type *p) - : p(coroutine_handle::from_promise(*p)) {} - - coroutine_handle p; -}; - - -minig mini_count(int n) { - for (int i = 0; i < n; i++) { - co_yield i; - } -} - -generator count(int n) { - for (int i = 0; i < n; ++i) - co_yield i; -} - -generator range(int from, int n) { - for (int i = from; i < n; ++i) - co_yield i; -} - -void test_count() { - const std::vector expect = {0, 1, 2, 3, 4}; - std::vector got; - for (auto x : count(5)) - got.push_back(x); - assert(expect == got); -} - -void test_range() { - int sum = 0; - for (auto v: range(1, 20)) - sum += v; - assert(sum == 190); -} - -void test_mini_generator() { - int sum = 0; - auto g = mini_count(5); - while (g.move_next()) { - sum += g.current_value(); - } - assert(sum == 10); -} - -int main() { - test_count(); - test_range(); - test_mini_generator(); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/go.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/go.pass.cpp new file mode 100644 index 0000000000000..1fdf2c8558eb8 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/go.pass.cpp @@ -0,0 +1,176 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +using namespace std::experimental; + +bool cancel = false; + +struct goroutine +{ + static int const N = 10; + static int count; + static coroutine_handle<> stack[N]; + + static void schedule(coroutine_handle<>& rh) + { + assert(count < N); + stack[count++] = rh; + rh = nullptr; + } + + ~goroutine() {} + + static void go(goroutine) {} + + static void run_one() + { + assert(count > 0); + stack[--count](); + } + + struct promise_type + { + suspend_never initial_suspend() { + return {}; + } + suspend_never final_suspend() { + return {}; + } + void return_void() {} + goroutine get_return_object() { + return{}; + } + void unhandled_exception() {} + }; +}; +int goroutine::count; +coroutine_handle<> goroutine::stack[N]; + +coroutine_handle workaround; + +class channel; + +struct push_awaiter { + channel* ch; + bool await_ready() {return false; } + void await_suspend(coroutine_handle<> rh); + void await_resume() {} +}; + +struct pull_awaiter { + channel * ch; + + bool await_ready(); + void await_suspend(coroutine_handle<> rh); + int await_resume(); +}; + +class channel +{ + using T = int; + + friend struct push_awaiter; + friend struct pull_awaiter; + + T const* pvalue = nullptr; + coroutine_handle<> reader = nullptr; + coroutine_handle<> writer = nullptr; +public: + push_awaiter push(T const& value) + { + assert(pvalue == nullptr); + assert(!writer); + pvalue = &value; + + return { this }; + } + + pull_awaiter pull() + { + assert(!reader); + + return { this }; + } + + void sync_push(T const& value) + { + assert(!pvalue); + pvalue = &value; + assert(reader); + reader(); + assert(!pvalue); + reader = nullptr; + } + + auto sync_pull() + { + while (!pvalue) goroutine::run_one(); + auto result = *pvalue; + pvalue = nullptr; + if (writer) + { + auto wr = writer; + writer = nullptr; + wr(); + } + return result; + } +}; + +void push_awaiter::await_suspend(coroutine_handle<> rh) +{ + ch->writer = rh; + if (ch->reader) goroutine::schedule(ch->reader); +} + + +bool pull_awaiter::await_ready() { + return !!ch->writer; +} +void pull_awaiter::await_suspend(coroutine_handle<> rh) { + ch->reader = rh; +} +int pull_awaiter::await_resume() { + auto result = *ch->pvalue; + ch->pvalue = nullptr; + if (ch->writer) { + //goroutine::schedule(ch->writer); + auto wr = ch->writer; + ch->writer = nullptr; + wr(); + } + return result; +} + +goroutine pusher(channel& left, channel& right) +{ + for (;;) { + auto val = co_await left.pull(); + co_await right.push(val + 1); + } +} + +const int N = 100; +channel* c = new channel[N + 1]; + +int main() { + for (int i = 0; i < N; ++i) + goroutine::go(pusher(c[i], c[i + 1])); + + c[0].sync_push(0); + int result = c[N].sync_pull(); + + assert(result == 100); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/go.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/go.sh.cpp deleted file mode 100644 index e0d69104fdaf4..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/go.sh.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include - -using namespace std::experimental; - -bool cancel = false; - -struct goroutine -{ - static int const N = 10; - static int count; - static coroutine_handle<> stack[N]; - - static void schedule(coroutine_handle<>& rh) - { - assert(count < N); - stack[count++] = rh; - rh = nullptr; - } - - ~goroutine() {} - - static void go(goroutine) {} - - static void run_one() - { - assert(count > 0); - stack[--count](); - } - - struct promise_type - { - suspend_never initial_suspend() { - return {}; - } - suspend_never final_suspend() { - return {}; - } - void return_void() {} - goroutine get_return_object() { - return{}; - } - void unhandled_exception() {} - }; -}; -int goroutine::count; -coroutine_handle<> goroutine::stack[N]; - -coroutine_handle workaround; - -class channel; - -struct push_awaiter { - channel* ch; - bool await_ready() {return false; } - void await_suspend(coroutine_handle<> rh); - void await_resume() {} -}; - -struct pull_awaiter { - channel * ch; - - bool await_ready(); - void await_suspend(coroutine_handle<> rh); - int await_resume(); -}; - -class channel -{ - using T = int; - - friend struct push_awaiter; - friend struct pull_awaiter; - - T const* pvalue = nullptr; - coroutine_handle<> reader = nullptr; - coroutine_handle<> writer = nullptr; -public: - push_awaiter push(T const& value) - { - assert(pvalue == nullptr); - assert(!writer); - pvalue = &value; - - return { this }; - } - - pull_awaiter pull() - { - assert(!reader); - - return { this }; - } - - void sync_push(T const& value) - { - assert(!pvalue); - pvalue = &value; - assert(reader); - reader(); - assert(!pvalue); - reader = nullptr; - } - - auto sync_pull() - { - while (!pvalue) goroutine::run_one(); - auto result = *pvalue; - pvalue = nullptr; - if (writer) - { - auto wr = writer; - writer = nullptr; - wr(); - } - return result; - } -}; - -void push_awaiter::await_suspend(coroutine_handle<> rh) -{ - ch->writer = rh; - if (ch->reader) goroutine::schedule(ch->reader); -} - - -bool pull_awaiter::await_ready() { - return !!ch->writer; -} -void pull_awaiter::await_suspend(coroutine_handle<> rh) { - ch->reader = rh; -} -int pull_awaiter::await_resume() { - auto result = *ch->pvalue; - ch->pvalue = nullptr; - if (ch->writer) { - //goroutine::schedule(ch->writer); - auto wr = ch->writer; - ch->writer = nullptr; - wr(); - } - return result; -} - -goroutine pusher(channel& left, channel& right) -{ - for (;;) { - auto val = co_await left.pull(); - co_await right.push(val + 1); - } -} - -const int N = 100; //100'000'000; -const int repeat = 1; - -channel* c = new channel[N + 1]; - -int main() { - for (int i = 0; i < N; ++i) - goroutine::go(pusher(c[i], c[i + 1])); - - c[0].sync_push(0); - int result = c[N].sync_pull(); - - assert(result == 100); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.pass.cpp new file mode 100644 index 0000000000000..e3c96530335d6 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.pass.cpp @@ -0,0 +1,87 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include + +using namespace std::experimental; + +// This file tests, multishot, movable std::function like thing using coroutine +// for compile-time type erasure and unerasure. +template struct func { + struct Input {R a, b;}; + + struct promise_type { + Input* I; + R result; + func get_return_object() { return {this}; } + suspend_always initial_suspend() { return {}; } + suspend_never final_suspend() { return {}; } + void return_void() {} + template + suspend_always yield_value(F&& f) { + result = f(I->a, I->b); + return {}; + } + void unhandled_exception() {} + }; + + R operator()(Input I) { + h.promise().I = &I; + h.resume(); + R result = h.promise().result; + return result; + }; + + func() {} + func(func &&rhs) : h(rhs.h) { rhs.h = nullptr; } + func(func const &) = delete; + + func &operator=(func &&rhs) { + if (this != &rhs) { + if (h) + h.destroy(); + h = rhs.h; + rhs.h = nullptr; + } + return *this; + } + + template static func Create(F f) { + for (;;) { + co_yield f; + } + } + + template func(F f) : func(Create(f)) {} + + ~func() { + if (h) + h.destroy(); + } + +private: + func(promise_type *promise) + : h(coroutine_handle::from_promise(*promise)) {} + coroutine_handle h; +}; + +int Do(int acc, int n, func f) { + for (int i = 0; i < n; ++i) + acc = f({acc, i}); + return acc; +} + +int main() { + int result = Do(1, 10, [](int a, int b) {return a + b;}); + assert(result == 46); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.sh.cpp deleted file mode 100644 index e13196c253ea1..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/multishot_func.sh.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include - -using namespace std::experimental; - -// This file tests, multishot, movable std::function like thing using coroutine -// for compile-time type erasure and unerasure. -template struct func { - struct Input {R a, b;}; - - struct promise_type { - Input* I; - R result; - func get_return_object() { return {this}; } - suspend_always initial_suspend() { return {}; } - suspend_never final_suspend() { return {}; } - void return_void() {} - template - suspend_always yield_value(F&& f) { - result = f(I->a, I->b); - return {}; - } - void unhandled_exception() {} - }; - - R operator()(Input I) { - h.promise().I = &I; - h.resume(); - R result = h.promise().result; - return result; - }; - - func() {} - func(func &&rhs) : h(rhs.h) { rhs.h = nullptr; } - func(func const &) = delete; - - func &operator=(func &&rhs) { - if (this != &rhs) { - if (h) - h.destroy(); - h = rhs.h; - rhs.h = nullptr; - } - return *this; - } - - template static func Create(F f) { - for (;;) { - co_yield f; - } - } - - template func(F f) : func(Create(f)) {} - - ~func() { - if (h) - h.destroy(); - } - -private: - func(promise_type *promise) - : h(coroutine_handle::from_promise(*promise)) {} - coroutine_handle h; -}; - -int Do(int acc, int n, func f) { - for (int i = 0; i < n; ++i) - acc = f({acc, i}); - return acc; -} - -int main() { - int result = Do(1, 10, [](int a, int b) {return a + b;}); - assert(result == 46); -} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp new file mode 100644 index 0000000000000..d5f2c40e2a799 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp @@ -0,0 +1,83 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include +#include + +using namespace std::experimental; + +// This file tests, one shot, movable std::function like thing using coroutine +// for compile-time type erasure and unerasure. + +template struct func { + struct promise_type { + R result; + func get_return_object() { return {this}; } + suspend_always initial_suspend() { return {}; } + suspend_always final_suspend() { return {}; } + void return_value(R v) { result = v; } + void unhandled_exception() {} + }; + + R operator()() { + h.resume(); + R result = h.promise().result; + h.destroy(); + h = nullptr; + return result; + }; + + func() {} + func(func &&rhs) : h(rhs.h) { rhs.h = nullptr; } + func(func const &) = delete; + + func &operator=(func &&rhs) { + if (this != &rhs) { + if (h) + h.destroy(); + h = rhs.h; + rhs.h = nullptr; + } + return *this; + } + + template static func Create(F f) { co_return f(); } + + template func(F f) : func(Create(f)) {} + + ~func() { + if (h) + h.destroy(); + } + +private: + func(promise_type *promise) + : h(coroutine_handle::from_promise(*promise)) {} + coroutine_handle h; +}; + +std::vector yielded_values = {}; +int yield(int x) { yielded_values.push_back(x); return x + 1; } +float fyield(int x) { yielded_values.push_back(x); return x + 2; } + +void Do1(func f) { yield(f()); } +void Do2(func f) { yield(f()); } + +int main() { + Do1([] { return yield(43); }); + assert((yielded_values == std::vector{43, 44})); + + yielded_values = {}; + Do2([] { return fyield(44); }); + assert((yielded_values == std::vector{44, 46})); +} diff --git a/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.sh.cpp b/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.sh.cpp deleted file mode 100644 index 9c94f73b2a70b..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.sh.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -#include -#include -#include - -using namespace std::experimental; - -// This file tests, one shot, movable std::function like thing using coroutine -// for compile-time type erasure and unerasure. - -template struct func { - struct promise_type { - R result; - func get_return_object() { return {this}; } - suspend_always initial_suspend() { return {}; } - suspend_always final_suspend() { return {}; } - void return_value(R v) { result = v; } - void unhandled_exception() {} - }; - - R operator()() { - h.resume(); - R result = h.promise().result; - h.destroy(); - h = nullptr; - return result; - }; - - func() {} - func(func &&rhs) : h(rhs.h) { rhs.h = nullptr; } - func(func const &) = delete; - - func &operator=(func &&rhs) { - if (this != &rhs) { - if (h) - h.destroy(); - h = rhs.h; - rhs.h = nullptr; - } - return *this; - } - - template static func Create(F f) { co_return f(); } - - template func(F f) : func(Create(f)) {} - - ~func() { - if (h) - h.destroy(); - } - -private: - func(promise_type *promise) - : h(coroutine_handle::from_promise(*promise)) {} - coroutine_handle h; -}; - -std::vector yielded_values = {}; -int yield(int x) { yielded_values.push_back(x); return x + 1; } -float fyield(int x) { yielded_values.push_back(x); return x + 2; } - -void Do1(func f) { yield(f()); } -void Do2(func f) { yield(f()); } - -int main() { - Do1([] { return yield(43); }); - assert((yielded_values == std::vector{43, 44})); - - yielded_values = {}; - Do2([] { return fyield(44); }); - assert((yielded_values == std::vector{44, 46})); -} diff --git a/test/std/experimental/language.support/support.coroutines/includes.pass.cpp b/test/std/experimental/language.support/support.coroutines/includes.pass.cpp new file mode 100644 index 0000000000000..b30d8c7ed24f4 --- /dev/null +++ b/test/std/experimental/language.support/support.coroutines/includes.pass.cpp @@ -0,0 +1,25 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// Test that includes + +#include + +int main(){ + // std::nothrow is not implicitly defined by the compiler when the include is + // missing, unlike other parts of . Therefore we use std::nothrow to + // test for #include + (void)std::nothrow; + +} diff --git a/test/std/experimental/language.support/support.coroutines/includes.sh.cpp b/test/std/experimental/language.support/support.coroutines/includes.sh.cpp deleted file mode 100644 index f9d8a572256cc..0000000000000 --- a/test/std/experimental/language.support/support.coroutines/includes.sh.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -*- 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// REQUIRES: fcoroutines-ts - -// RUN: %build -fcoroutines-ts -// RUN: %run - -// - -// Test that includes - -#include - - - -int main(){ - // std::nothrow is not implicitly defined by the compiler when the include is - // missing, unlike other parts of . Therefore we use std::nothrow to - // test for #include - (void)std::nothrow; - -} diff --git a/test/support/nasty_macros.hpp b/test/support/nasty_macros.hpp index f6c8aaddbea60..ff141f7954c88 100644 --- a/test/support/nasty_macros.hpp +++ b/test/support/nasty_macros.hpp @@ -37,6 +37,14 @@ #define _Y NASTY_MACRO #define _Z NASTY_MACRO +// tchar.h defines these macros on Windows. +#define _UI NASTY_MACRO +#define _PUC NASTY_MACRO +#define _CPUC NASTY_MACRO +#define _PC NASTY_MACRO +#define _CRPC NASTY_MACRO +#define _CPC NASTY_MACRO + // Test that libc++ doesn't use names reserved by WIN32 API Macros. // NOTE: Obviously we can only define these on non-windows platforms. #ifndef _WIN32 diff --git a/test/support/test_macros.h b/test/support/test_macros.h index 637686284ed24..cc2918a0875a2 100644 --- a/test/support/test_macros.h +++ b/test/support/test_macros.h @@ -195,7 +195,7 @@ struct is_same { enum {value = 1}; }; #define ASSERT_SAME_TYPE(...) \ static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \ - "Types differ uexpectedly") + "Types differ unexpectedly") #ifndef TEST_HAS_NO_EXCEPTIONS #define TEST_THROW(...) throw __VA_ARGS__ diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py index 1bf2677a8509c..0fbc2cf4ea620 100644 --- a/utils/libcxx/test/config.py +++ b/utils/libcxx/test/config.py @@ -484,9 +484,13 @@ class Configuration(object): # Configure extra flags compile_flags_str = self.get_lit_conf('compile_flags', '') self.cxx.compile_flags += shlex.split(compile_flags_str) - # FIXME: Can we remove this? if self.is_windows: + # FIXME: Can we remove this? self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS'] + # Required so that tests using min/max don't fail on Windows, + # and so that those tests don't have to be changed to tolerate + # this insanity. + self.cxx.compile_flags += ['-DNOMINMAX'] def configure_default_compile_flags(self): # Try and get the std version from the command line. Fall back to -- cgit v1.3