diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
commit | 0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch) | |
tree | 051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test | |
parent | 868847c6900e575417c03bced6e562b3af891318 (diff) |
Notes
Diffstat (limited to 'test')
807 files changed, 9775 insertions, 10908 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ad110fbfb30b6..6f2eac0546fcf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,3 @@ -include(AddLLVM) # for add_lit_testsuite - macro(pythonize_bool var) if (${var}) set(${var} True) @@ -35,6 +33,7 @@ pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) +pythonize_bool(LIBCXX_DEBUG_BUILD) # By default, for non-standalone builds, libcxx and libcxxabi share a library # directory. @@ -61,21 +60,28 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) set(LIBCXX_TEST_DEPS cxx_experimental) endif() -if (LIBCXX_HAS_EXTERNAL_THREAD_API) +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) list(APPEND LIBCXX_TEST_DEPS cxx_external_threads) endif() -add_lit_testsuite(check-cxx - "Running libcxx tests" - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS cxx ${LIBCXX_TEST_DEPS}) +if (LIBCXX_INCLUDE_TESTS) + include(AddLLVM) # for add_lit_testsuite + add_lit_testsuite(check-cxx + "Running libcxx tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS cxx ${LIBCXX_TEST_DEPS}) -add_custom_target(check-libcxx DEPENDS check-cxx) + add_custom_target(check-libcxx DEPENDS check-cxx) +endif() if (LIBCXX_GENERATE_COVERAGE) include(CodeCoverage) set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") - set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/;${CMAKE_CURRENT_BINARY_DIR}") + set(capture_dirs + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/" + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/" + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/" + "${CMAKE_CURRENT_BINARY_DIR}") set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src") setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}") endif() diff --git a/test/libcxx/__init__.py b/test/libcxx/__init__.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 --- a/test/libcxx/__init__.py +++ /dev/null diff --git a/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp new file mode 100644 index 0000000000000..8214e1e206861 --- /dev/null +++ b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class RandomAccessIterator> +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template <class RandomAccessIterator, class RandomNumberGenerator> +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last, +// RandomNumberGenerator& rand); + +// +// In C++17, random_shuffle has been removed. +// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +// is defined before including <algorithm>, then random_shuffle will be restored. + +#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE + +#include <algorithm> +#include <vector> + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +int main() +{ + std::vector<int> v; + std::random_shuffle(v.begin(), v.end()); + gen r; + std::random_shuffle(v.begin(), v.end(), r); +} diff --git a/test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp b/test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp new file mode 100644 index 0000000000000..d8bb363d86b08 --- /dev/null +++ b/test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support, diagnose-if-support +// UNSUPPORTED: libcpp-has-no-threads + +// <atomic> + +// Test that invalid memory order arguments are diagnosed where possible. + +#include <atomic> + +int main() { + std::atomic<int> x(42); + volatile std::atomic<int>& vx = x; + int val1 = 1; ((void)val1); + int val2 = 2; ((void)val2); + // load operations + { + x.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.load(std::memory_order_relaxed); + x.load(std::memory_order_consume); + x.load(std::memory_order_acquire); + x.load(std::memory_order_seq_cst); + } + { + std::atomic_load_explicit(&x, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&x, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&vx, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_load_explicit(&vx, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_load_explicit(&x, std::memory_order_relaxed); + std::atomic_load_explicit(&x, std::memory_order_consume); + std::atomic_load_explicit(&x, std::memory_order_acquire); + std::atomic_load_explicit(&x, std::memory_order_seq_cst); + } + // store operations + { + x.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + x.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + x.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.store(42, std::memory_order_relaxed); + x.store(42, std::memory_order_release); + x.store(42, std::memory_order_seq_cst); + } + { + std::atomic_store_explicit(&x, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&x, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&x, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_store_explicit(&vx, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_store_explicit(&x, 42, std::memory_order_relaxed); + std::atomic_store_explicit(&x, 42, std::memory_order_release); + std::atomic_store_explicit(&x, 42, std::memory_order_seq_cst); + } + // compare exchange weak + { + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + // Test that the cmpxchg overload with only one memory order argument + // does not generate any diagnostics. + x.compare_exchange_weak(val1, val2, std::memory_order_release); + } + { + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + } + // compare exchange strong + { + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + // Test that the cmpxchg overload with only one memory order argument + // does not generate any diagnostics. + x.compare_exchange_strong(val1, val2, std::memory_order_release); + } + { + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}} + std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}} + // valid memory orders + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire); + std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst); + } +} diff --git a/test/libcxx/compiler.py b/test/libcxx/compiler.py deleted file mode 100644 index 8585f44ed35fd..0000000000000 --- a/test/libcxx/compiler.py +++ /dev/null @@ -1,302 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -import platform -import os -import lit.util -import libcxx.util - - -class CXXCompiler(object): - CM_Default = 0 - CM_PreProcess = 1 - CM_Compile = 2 - CM_Link = 3 - - def __init__(self, path, flags=None, compile_flags=None, link_flags=None, - warning_flags=None, verify_supported=None, - verify_flags=None, use_verify=False, - modules_flags=None, use_modules=False, - use_ccache=False, use_warnings=False, compile_env=None, - cxx_type=None, cxx_version=None): - self.path = path - self.flags = list(flags or []) - self.compile_flags = list(compile_flags or []) - self.link_flags = list(link_flags or []) - self.warning_flags = list(warning_flags or []) - self.verify_supported = verify_supported - self.use_verify = use_verify - self.verify_flags = list(verify_flags or []) - assert not use_verify or verify_supported - assert not use_verify or verify_flags is not None - self.modules_flags = list(modules_flags or []) - self.use_modules = use_modules - assert not use_modules or modules_flags is not None - self.use_ccache = use_ccache - self.use_warnings = use_warnings - if compile_env is not None: - self.compile_env = dict(compile_env) - else: - self.compile_env = None - self.type = cxx_type - self.version = cxx_version - if self.type is None or self.version is None: - self._initTypeAndVersion() - - def copy(self): - new_cxx = CXXCompiler( - self.path, flags=self.flags, compile_flags=self.compile_flags, - link_flags=self.link_flags, warning_flags=self.warning_flags, - verify_supported=self.verify_supported, - verify_flags=self.verify_flags, use_verify=self.use_verify, - modules_flags=self.modules_flags, use_modules=self.use_modules, - use_ccache=self.use_ccache, use_warnings=self.use_warnings, - compile_env=self.compile_env, cxx_type=self.type, - cxx_version=self.version) - return new_cxx - - def isVerifySupported(self): - if self.verify_supported is None: - self.verify_supported = self.hasCompileFlag(['-Xclang', - '-verify-ignore-unexpected']) - if self.verify_supported: - self.verify_flags = [ - '-Xclang', '-verify', - '-Xclang', '-verify-ignore-unexpected=note', - '-ferror-limit=1024' - ] - return self.verify_supported - - def useVerify(self, value=True): - self.use_verify = value - assert not self.use_verify or self.verify_flags is not None - - def useModules(self, value=True): - self.use_modules = value - assert not self.use_modules or self.modules_flags is not None - - def useCCache(self, value=True): - self.use_ccache = value - - def useWarnings(self, value=True): - self.use_warnings = value - - def _initTypeAndVersion(self): - # Get compiler type and version - macros = self.dumpMacros() - if macros is None: - return - compiler_type = None - major_ver = minor_ver = patchlevel = None - if '__clang__' in macros.keys(): - compiler_type = 'clang' - # Treat apple's llvm fork differently. - if '__apple_build_version__' in macros.keys(): - compiler_type = 'apple-clang' - major_ver = macros['__clang_major__'] - minor_ver = macros['__clang_minor__'] - patchlevel = macros['__clang_patchlevel__'] - elif '__GNUC__' in macros.keys(): - compiler_type = 'gcc' - major_ver = macros['__GNUC__'] - minor_ver = macros['__GNUC_MINOR__'] - patchlevel = macros['__GNUC_PATCHLEVEL__'] - self.type = compiler_type - self.version = (major_ver, minor_ver, patchlevel) - - def _basicCmd(self, source_files, out, mode=CM_Default, flags=[], - input_is_cxx=False): - cmd = [] - if self.use_ccache \ - and not mode == self.CM_Link \ - and not mode == self.CM_PreProcess: - cmd += ['ccache'] - cmd += [self.path] - if out is not None: - cmd += ['-o', out] - if input_is_cxx: - cmd += ['-x', 'c++'] - if isinstance(source_files, list): - cmd += source_files - elif isinstance(source_files, str): - cmd += [source_files] - else: - raise TypeError('source_files must be a string or list') - if mode == self.CM_PreProcess: - cmd += ['-E'] - elif mode == self.CM_Compile: - cmd += ['-c'] - cmd += self.flags - if self.use_verify: - cmd += self.verify_flags - assert mode in [self.CM_Default, self.CM_Compile] - if self.use_modules: - cmd += self.modules_flags - if mode != self.CM_Link: - cmd += self.compile_flags - if self.use_warnings: - cmd += self.warning_flags - if mode != self.CM_PreProcess and mode != self.CM_Compile: - cmd += self.link_flags - cmd += flags - return cmd - - def preprocessCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_PreProcess, - input_is_cxx=True) - - def compileCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_Compile, - input_is_cxx=True) + ['-c'] - - def linkCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags, - mode=self.CM_Link) - - def compileLinkCmd(self, source_files, out=None, flags=[]): - return self._basicCmd(source_files, out, flags=flags) - - def preprocess(self, source_files, out=None, flags=[], cwd=None): - cmd = self.preprocessCmd(source_files, out, flags) - out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def compile(self, source_files, out=None, flags=[], cwd=None): - cmd = self.compileCmd(source_files, out, flags) - out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def link(self, source_files, out=None, flags=[], cwd=None): - cmd = self.linkCmd(source_files, out, flags) - out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def compileLink(self, source_files, out=None, flags=[], - cwd=None): - cmd = self.compileLinkCmd(source_files, out, flags) - out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env, - cwd=cwd) - return cmd, out, err, rc - - def compileLinkTwoSteps(self, source_file, out=None, object_file=None, - flags=[], cwd=None): - if not isinstance(source_file, str): - raise TypeError('This function only accepts a single input file') - if object_file is None: - # Create, use and delete a temporary object file if none is given. - with_fn = lambda: libcxx.util.guardedTempFilename(suffix='.o') - else: - # Otherwise wrap the filename in a context manager function. - with_fn = lambda: libcxx.util.nullContext(object_file) - with with_fn() as object_file: - cc_cmd, cc_stdout, cc_stderr, rc = self.compile( - source_file, object_file, flags=flags, cwd=cwd) - if rc != 0: - return cc_cmd, cc_stdout, cc_stderr, rc - - link_cmd, link_stdout, link_stderr, rc = self.link( - object_file, out=out, flags=flags, cwd=cwd) - return (cc_cmd + ['&&'] + link_cmd, cc_stdout + link_stdout, - cc_stderr + link_stderr, rc) - - def dumpMacros(self, source_files=None, flags=[], cwd=None): - if source_files is None: - source_files = os.devnull - flags = ['-dM'] + flags - cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd) - if rc != 0: - return None - parsed_macros = {} - lines = [l.strip() for l in out.split('\n') if l.strip()] - for l in lines: - assert l.startswith('#define ') - l = l[len('#define '):] - macro, _, value = l.partition(' ') - parsed_macros[macro] = value - return parsed_macros - - def getTriple(self): - cmd = [self.path] + self.flags + ['-dumpmachine'] - return lit.util.capture(cmd).strip() - - def hasCompileFlag(self, flag): - if isinstance(flag, list): - flags = list(flag) - else: - flags = [flag] - # Add -Werror to ensure that an unrecognized flag causes a non-zero - # exit code. -Werror is supported on all known compiler types. - if self.type is not None: - flags += ['-Werror', '-fsyntax-only'] - cmd, out, err, rc = self.compile(os.devnull, out=os.devnull, - flags=flags) - return rc == 0 - - def addFlagIfSupported(self, flag): - if isinstance(flag, list): - flags = list(flag) - else: - flags = [flag] - if self.hasCompileFlag(flags): - self.flags += flags - return True - else: - return False - - def addCompileFlagIfSupported(self, flag): - if isinstance(flag, list): - flags = list(flag) - else: - flags = [flag] - if self.hasCompileFlag(flags): - self.compile_flags += flags - return True - else: - return False - - def hasWarningFlag(self, flag): - """ - hasWarningFlag - Test if the compiler supports a given warning flag. - Unlike addCompileFlagIfSupported, this function detects when - "-Wno-<warning>" flags are unsupported. If flag is a - "-Wno-<warning>" GCC will not emit an unknown option diagnostic unless - another error is triggered during compilation. - """ - assert isinstance(flag, str) - assert flag.startswith('-W') - if not flag.startswith('-Wno-'): - return self.hasCompileFlag(flag) - flags = ['-Werror', flag] - old_use_warnings = self.use_warnings - self.useWarnings(False) - cmd = self.compileCmd('-', os.devnull, flags) - self.useWarnings(old_use_warnings) - # Remove '-v' because it will cause the command line invocation - # to be printed as part of the error output. - # TODO(EricWF): Are there other flags we need to worry about? - if '-v' in cmd: - cmd.remove('-v') - out, err, rc = lit.util.executeCommand(cmd, input='#error\n') - - assert rc != 0 - if flag in err: - return False - return True - - def addWarningFlagIfSupported(self, flag): - if self.hasWarningFlag(flag): - assert flag not in self.warning_flags - self.warning_flags += [flag] - return True - return False diff --git a/test/libcxx/containers/associative/non_const_comparator.fail.cpp b/test/libcxx/containers/associative/non_const_comparator.fail.cpp new file mode 100644 index 0000000000000..ea0d9ac09328e --- /dev/null +++ b/test/libcxx/containers/associative/non_const_comparator.fail.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// REQUIRES: diagnose-if-support, verify-support + +// Test that libc++ generates a warning diagnostic when the container is +// provided a non-const callable comparator. + +#include <set> +#include <map> + +struct BadCompare { + template <class T, class U> + bool operator()(T const& t, U const& u) { + return t < u; + } +}; + +int main() { + static_assert(!std::__invokable<BadCompare const&, int const&, int const&>::value, ""); + static_assert(std::__invokable<BadCompare&, int const&, int const&>::value, ""); + + // expected-warning@__tree:* 4 {{the specified comparator type does not provide a const call operator}} + { + using C = std::set<int, BadCompare>; + C s; + } + { + using C = std::multiset<long, BadCompare>; + C s; + } + { + using C = std::map<int, int, BadCompare>; + C s; + } + { + using C = std::multimap<long, int, BadCompare>; + C s; + } +} diff --git a/test/libcxx/containers/associative/undef_min_max.pass.cpp b/test/libcxx/containers/associative/undef_min_max.pass.cpp index b108f0ce5736c..be5e110529e27 100644 --- a/test/libcxx/containers/associative/undef_min_max.pass.cpp +++ b/test/libcxx/containers/associative/undef_min_max.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic ignored "-W#warnings" #endif diff --git a/test/libcxx/containers/unord/non_const_comparator.fail.cpp b/test/libcxx/containers/unord/non_const_comparator.fail.cpp new file mode 100644 index 0000000000000..8adc67589ef88 --- /dev/null +++ b/test/libcxx/containers/unord/non_const_comparator.fail.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// REQUIRES: diagnose-if-support, verify-support + +// Test that libc++ generates a warning diagnostic when the container is +// provided a non-const callable comparator. + +#include <unordered_set> +#include <unordered_map> + +struct BadHash { + template <class T> + size_t operator()(T const& t) { + return std::hash<T>{}(t); + } +}; + +struct BadEqual { + template <class T, class U> + bool operator()(T const& t, U const& u) { + return t == u; + } +}; + +int main() { + static_assert(!std::__invokable<BadEqual const&, int const&, int const&>::value, ""); + static_assert(std::__invokable<BadEqual&, int const&, int const&>::value, ""); + + // expected-warning@__hash_table:* 4 {{the specified comparator type does not provide a const call operator}} + // expected-warning@__hash_table:* 4 {{the specified hash functor does not provide a const call operator}} + + { + using C = std::unordered_set<int, BadHash, BadEqual>; + C s; + } + { + using C = std::unordered_multiset<long, BadHash, BadEqual>; + C s; + } + { + using C = std::unordered_map<int, int, BadHash, BadEqual>; + C s; + } + { + using C = std::unordered_multimap<long, int, BadHash, BadEqual>; + C s; + } +} diff --git a/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp b/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp new file mode 100644 index 0000000000000..d6554a63c59c9 --- /dev/null +++ b/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: diagnose-if-support +// UNSUPPORTED: c++98, c++03 + +// Libc++ only provides a defined primary template for std::hash in C++14 and +// newer. +// UNSUPPORTED: c++11 + +// <unordered_set> + +// Test that we generate a reasonable diagnostic when the specified hash is +// not enabled. + +#include <unordered_set> +#include <utility> + +using VT = std::pair<int, int>; + +struct BadHashNoCopy { + BadHashNoCopy() = default; + BadHashNoCopy(BadHashNoCopy const&) = delete; + + template <class T> + size_t operator()(T const&) const { return 0; } +}; + +struct BadHashNoCall { + +}; + + +struct GoodHashNoDefault { + explicit GoodHashNoDefault(void*) {} + template <class T> + size_t operator()(T const&) const { return 0; } +}; + +int main() { + + { + using Set = std::unordered_set<VT>; + Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}} + + + // FIXME: It would be great to suppress the below diagnostic all together. + // but for now it's sufficient that it appears last. However there is + // currently no way to test the order diagnostics are issued. + // expected-error@memory:* {{call to implicitly-deleted default constructor of '__compressed_pair_elem}} + } + { + using Set = std::unordered_set<int, BadHashNoCopy>; + Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}} + } + { + using Set = std::unordered_set<int, BadHashNoCall>; + Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}} + } + { + using Set = std::unordered_set<int, GoodHashNoDefault>; + Set s(/*bucketcount*/42, GoodHashNoDefault(nullptr)); + } +} diff --git a/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp b/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp index c2c2d9221cf12..91cdf85b1586d 100644 --- a/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp +++ b/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp @@ -9,11 +9,14 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr +// MODULES_DEFINES: _LIBCPP_DEBUG=1 +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS // test container debugging #define _LIBCPP_DEBUG 1 #define _LIBCPP_DEBUG_USE_EXCEPTIONS + #include <map> #include <set> #include <utility> diff --git a/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp b/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp index 46f960c15b1e2..6e2fb7bf3d0c2 100644 --- a/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp +++ b/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp @@ -9,6 +9,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr +// MODULES_DEFINES: _LIBCPP_DEBUG=1 +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS // test container debugging diff --git a/test/libcxx/debug/containers/db_string.pass.cpp b/test/libcxx/debug/containers/db_string.pass.cpp index ee1634140ff66..8d1a622b4ffe6 100644 --- a/test/libcxx/debug/containers/db_string.pass.cpp +++ b/test/libcxx/debug/containers/db_string.pass.cpp @@ -9,6 +9,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr +// MODULES_DEFINES: _LIBCPP_DEBUG=1 +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS // test container debugging @@ -38,8 +40,7 @@ struct StringContainerChecks : BasicContainerChecks<Container, CT> { public: static void run() { Base::run_iterator_tests(); - // FIXME: get these passing - // Base::run_allocator_aware_tests(); + Base::run_allocator_aware_tests(); try { for (int N : {3, 128}) { FrontOnEmptyContainer(N); diff --git a/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp b/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp index 708fc7f8b9500..5618607fbc25d 100644 --- a/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp +++ b/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp @@ -9,6 +9,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr +// MODULES_DEFINES: _LIBCPP_DEBUG=1 +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS // test container debugging diff --git a/test/libcxx/debug/debug_abort.pass.cpp b/test/libcxx/debug/debug_abort.pass.cpp index cfe63202705d8..b6e7b0bd805b6 100644 --- a/test/libcxx/debug/debug_abort.pass.cpp +++ b/test/libcxx/debug/debug_abort.pass.cpp @@ -7,6 +7,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + +// MODULES_DEFINES: _LIBCPP_DEBUG=0 + // Test that the default debug handler aborts the program. #define _LIBCPP_DEBUG 0 diff --git a/test/libcxx/debug/debug_throw.pass.cpp b/test/libcxx/debug/debug_throw.pass.cpp index bc5625c60093c..716750c7859ab 100644 --- a/test/libcxx/debug/debug_throw.pass.cpp +++ b/test/libcxx/debug/debug_throw.pass.cpp @@ -7,7 +7,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + // UNSUPPORTED: libcpp-no-exceptions +// MODULES_DEFINES: _LIBCPP_DEBUG=0 // Test that the default debug handler can be overridden and test the // throwing debug handler. diff --git a/test/libcxx/debug/debug_throw_register.pass.cpp b/test/libcxx/debug/debug_throw_register.pass.cpp index 21b1d5255d3d5..ec4be700e190e 100644 --- a/test/libcxx/debug/debug_throw_register.pass.cpp +++ b/test/libcxx/debug/debug_throw_register.pass.cpp @@ -7,7 +7,10 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + // UNSUPPORTED: libcpp-no-exceptions +// MODULES_DEFINES: _LIBCPP_DEBUG=1 +// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS // Test that defining _LIBCPP_DEBUG_USE_EXCEPTIONS causes _LIBCPP_ASSERT // to throw on failure. diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp index e7ad6ad7ef33d..41ddb179ff947 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp +++ b/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp @@ -9,26 +9,21 @@ // <memory> -// unique_ptr +// template <class X> +// class auto_ptr; +// +// In C++17, auto_ptr has been removed. +// However, for backwards compatibility, if _LIBCPP_NO_REMOVE_AUTOPTR +// is defined before including <memory>, then auto_ptr will be restored. + +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -// Test unique_ptr<T[]>::pointer type +#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR #include <memory> #include <type_traits> -struct Deleter -{ - struct pointer {}; -}; - int main() { - { - typedef std::unique_ptr<int[]> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int[], Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } + std::auto_ptr<int> p; } diff --git a/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp b/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp new file mode 100644 index 0000000000000..424fe52b31199 --- /dev/null +++ b/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + + +// In C++17, the function adapters mem_fun/mem_fun_ref, etc have been removed. +// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +// is defined before including <functional>, then they will be restored. + +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include <functional> +#include <cassert> + +int identity(int v) { return v; } +int sum(int a, int b) { return a + b; } + +struct Foo { + int zero() const { return 0; } + int identity(int v) const { return v; } + int sum(int a, int b) const { return a + b; } +}; + +int main() +{ + typedef std::pointer_to_unary_function<int, int> PUF; + typedef std::pointer_to_binary_function<int, int, int> PBF; + assert((std::ptr_fun<int, int>(identity)(4) == 4)); + assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9)); + + Foo f; + assert((std::mem_fn(&Foo::identity)(f, 5) == 5)); + assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11)); + + typedef std::mem_fun_ref_t<int, Foo> MFR; + typedef std::const_mem_fun_ref_t<int, Foo> CMFR; + + assert((std::mem_fun_ref(&Foo::zero)(f) == 0)); + assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5)); +} diff --git a/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp b/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp new file mode 100644 index 0000000000000..9f8a9c0888bad --- /dev/null +++ b/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 defining _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES correctly defines +// _LIBCPP_ENABLE_CXX17_REMOVED_FOO for each individual component macro. + +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#include <__config> + +#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#error _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS must be defined +#endif + +#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR +#error _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR must be defined +#endif + +int main() { +} diff --git a/test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp b/test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp new file mode 100644 index 0000000000000..55e23b9eda596 --- /dev/null +++ b/test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 get_unexpected + + +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#include <exception> +#include <cassert> +#include <cstdlib> + +void f1() {} +void f2() {} + +void f3() +{ + std::exit(0); +} + +int main() +{ + + std::unexpected_handler old = std::get_unexpected(); + // verify there is a previous unexpected handler + assert(old); + std::set_unexpected(f1); + assert(std::get_unexpected() == f1); + // verify f1 was replace with f2 + std::set_unexpected(f2); + assert(std::get_unexpected() == f2); + // verify calling original unexpected handler calls terminate + std::set_terminate(f3); + (*old)(); + assert(0); +} diff --git a/test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp b/test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp new file mode 100644 index 0000000000000..c4915dd100639 --- /dev/null +++ b/test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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 set_unexpected + +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#include <exception> +#include <cassert> +#include <cstdlib> + +void f1() {} +void f2() {} + +void f3() +{ + std::exit(0); +} + +int main() +{ + std::unexpected_handler old = std::set_unexpected(f1); + // verify there is a previous unexpected handler + assert(old); + // verify f1 was replace with f2 + assert(std::set_unexpected(f2) == f1); + // verify calling original unexpected handler calls terminate + std::set_terminate(f3); + (*old)(); + assert(0); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/test/libcxx/depr/exception.unexpected/unexpected.pass.cpp index 1c90ba76af393..7a84b92ca98a8 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp +++ b/test/libcxx/depr/exception.unexpected/unexpected.pass.cpp @@ -7,24 +7,22 @@ // //===----------------------------------------------------------------------===// -// <memory> +// test unexpected -// unique_ptr - -// test op->() - -#include <memory> +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +#include <exception> +#include <cstdlib> #include <cassert> -struct A +void fexit() { - int i_; - - A() : i_(7) {} -}; + std::exit(0); +} int main() { - std::unique_ptr<A[]> p(new A); - assert(p->i_ == 7); + std::set_unexpected(fexit); + std::unexpected(); + assert(false); } diff --git a/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp b/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp new file mode 100644 index 0000000000000..2a2917625fe58 --- /dev/null +++ b/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 + +// test unexpected + +#include <exception> + +void f() {} + +int main() { + using T = std::unexpected_handler; // expected-error {{no type named 'unexpected_handler' in namespace 'std'}} + std::unexpected(); // expected-error {{no member named 'unexpected' in namespace 'std'}} + std::get_unexpected(); // expected-error {{no member named 'get_unexpected' in namespace 'std'}} + std::set_unexpected(f); // expected-error {{no type named 'set_unexpected' in namespace 'std'}} +} diff --git a/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp b/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp new file mode 100644 index 0000000000000..6f839befb5cf0 --- /dev/null +++ b/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <experimental/filesystem> + +// class path + +#include <experimental/filesystem> +#include <iterator> + + +namespace fs = std::experimental::filesystem; + +int main() { + using namespace fs; + using RIt = std::reverse_iterator<path::iterator>; + + // expected-error@iterator:* {{static_assert failed "The specified iterator type cannot be used with reverse_iterator; Using stashing iterators with reverse_iterator causes undefined behavior"}} + { + RIt r; + ((void)r); + } +} diff --git a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp deleted file mode 100644 index ac685a99be494..0000000000000 --- a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// REQUIRES: c++experimental -// UNSUPPORTED: c++98, c++03 - -// <experimental/memory_resource> - -// template <class T> class polymorphic_allocator - -// EXTENSION -// std::size_t polymorphic_allocator<T>::max_size() const noexcept - -#include <experimental/memory_resource> -#include <type_traits> -#include <cassert> - -#include "test_memory_resource.hpp" - -namespace ex = std::experimental::pmr; - -template <std::size_t S> -std::size_t getMaxSize() { - using T = typename std::aligned_storage<S>::type; - static_assert(sizeof(T) == S, "Required for test"); - return ex::polymorphic_allocator<T>{}.max_size(); -} - -template <std::size_t S, std::size_t A> -std::size_t getMaxSize() { - using T = typename std::aligned_storage<S, A>::type; - static_assert(sizeof(T) == S, "Required for test"); - return ex::polymorphic_allocator<T>{}.max_size(); -} - -int main() -{ - { - using Alloc = ex::polymorphic_allocator<int>; - using Traits = std::allocator_traits<Alloc>; - const Alloc a; - static_assert(std::is_same<decltype(a.max_size()), Traits::size_type>::value, ""); - static_assert(noexcept(a.max_size()), ""); - } - { - constexpr std::size_t Max = std::numeric_limits<std::size_t>::max(); - assert(getMaxSize<1>() == Max); - assert(getMaxSize<2>() == Max / 2); - assert(getMaxSize<4>() == Max / 4); - assert(getMaxSize<8>() == Max / 8); - assert(getMaxSize<16>() == Max / 16); - assert(getMaxSize<32>() == Max / 32); - assert(getMaxSize<64>() == Max / 64); - assert(getMaxSize<1024>() == Max / 1024); - - assert((getMaxSize<6, 2>() == Max / 6)); - assert((getMaxSize<12, 4>() == Max / 12)); - } -} diff --git a/test/libcxx/test/__init__.py b/test/libcxx/test/__init__.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 --- a/test/libcxx/test/__init__.py +++ /dev/null diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py deleted file mode 100644 index 3d790249ce663..0000000000000 --- a/test/libcxx/test/config.py +++ /dev/null @@ -1,931 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -import locale -import os -import platform -import pkgutil -import re -import shlex -import shutil -import sys - -import lit.Test # pylint: disable=import-error,no-name-in-module -import lit.util # pylint: disable=import-error,no-name-in-module - -from libcxx.test.format import LibcxxTestFormat -from libcxx.compiler import CXXCompiler -from libcxx.test.target_info import make_target_info -from libcxx.test.executor import * -from libcxx.test.tracing import * - -def loadSiteConfig(lit_config, config, param_name, env_name): - # We haven't loaded the site specific configuration (the user is - # probably trying to run on a test file directly, and either the site - # configuration hasn't been created by the build system, or we are in an - # out-of-tree build situation). - site_cfg = lit_config.params.get(param_name, - os.environ.get(env_name)) - if not site_cfg: - lit_config.warning('No site specific configuration file found!' - ' Running the tests in the default configuration.') - elif not os.path.isfile(site_cfg): - lit_config.fatal( - "Specified site configuration file does not exist: '%s'" % - site_cfg) - else: - lit_config.note('using site specific configuration at %s' % site_cfg) - ld_fn = lit_config.load_config - - # Null out the load_config function so that lit.site.cfg doesn't - # recursively load a config even if it tries. - # TODO: This is one hell of a hack. Fix it. - def prevent_reload_fn(*args, **kwargs): - pass - lit_config.load_config = prevent_reload_fn - ld_fn(config, site_cfg) - lit_config.load_config = ld_fn - -class Configuration(object): - # pylint: disable=redefined-outer-name - def __init__(self, lit_config, config): - self.lit_config = lit_config - self.config = config - self.is_windows = platform.system() == 'Windows' - self.cxx = None - self.cxx_is_clang_cl = None - self.cxx_stdlib_under_test = None - self.project_obj_root = None - self.libcxx_src_root = None - self.libcxx_obj_root = None - self.cxx_library_root = None - self.cxx_runtime_root = None - self.abi_library_root = None - self.link_shared = self.get_lit_bool('enable_shared', default=True) - self.exec_env = {} - self.use_target = False - self.use_system_cxx_lib = False - self.use_clang_verify = False - self.long_tests = None - self.execute_external = False - - def get_lit_conf(self, name, default=None): - val = self.lit_config.params.get(name, None) - if val is None: - val = getattr(self.config, name, None) - if val is None: - val = default - return val - - def get_lit_bool(self, name, default=None): - conf = self.get_lit_conf(name) - if conf is None: - return default - if isinstance(conf, bool): - return conf - if not isinstance(conf, str): - raise TypeError('expected bool or string') - if conf.lower() in ('1', 'true'): - return True - if conf.lower() in ('', '0', 'false'): - return False - self.lit_config.fatal( - "parameter '{}' should be true or false".format(name)) - - def make_static_lib_name(self, name): - """Return the full filename for the specified library name""" - if self.is_windows: - return name + '.lib' - else: - return 'lib' + name + '.a' - - def configure(self): - self.configure_executor() - self.configure_target_info() - self.configure_cxx() - self.configure_triple() - self.configure_src_root() - self.configure_obj_root() - self.configure_cxx_stdlib_under_test() - self.configure_cxx_library_root() - self.configure_use_system_cxx_lib() - self.configure_use_clang_verify() - self.configure_use_thread_safety() - self.configure_execute_external() - self.configure_ccache() - self.configure_compile_flags() - self.configure_filesystem_compile_flags() - self.configure_link_flags() - self.configure_env() - self.configure_color_diagnostics() - self.configure_debug_mode() - self.configure_warnings() - self.configure_sanitizer() - self.configure_coverage() - self.configure_modules() - self.configure_substitutions() - self.configure_features() - - def print_config_info(self): - # Print the final compile and link flags. - self.lit_config.note('Using compiler: %s' % self.cxx.path) - self.lit_config.note('Using flags: %s' % self.cxx.flags) - if self.cxx.use_modules: - self.lit_config.note('Using modules flags: %s' % - self.cxx.modules_flags) - self.lit_config.note('Using compile flags: %s' - % self.cxx.compile_flags) - if len(self.cxx.warning_flags): - self.lit_config.note('Using warnings: %s' % self.cxx.warning_flags) - self.lit_config.note('Using link flags: %s' % self.cxx.link_flags) - # Print as list to prevent "set([...])" from being printed. - self.lit_config.note('Using available_features: %s' % - list(self.config.available_features)) - self.lit_config.note('Using environment: %r' % self.exec_env) - - def get_test_format(self): - return LibcxxTestFormat( - self.cxx, - self.use_clang_verify, - self.execute_external, - self.executor, - exec_env=self.exec_env) - - def configure_executor(self): - exec_str = self.get_lit_conf('executor', "None") - te = eval(exec_str) - if te: - self.lit_config.note("Using executor: %r" % exec_str) - if self.lit_config.useValgrind: - # We have no way of knowing where in the chain the - # ValgrindExecutor is supposed to go. It is likely - # that the user wants it at the end, but we have no - # way of getting at that easily. - selt.lit_config.fatal("Cannot infer how to create a Valgrind " - " executor.") - else: - te = LocalExecutor() - if self.lit_config.useValgrind: - te = ValgrindExecutor(self.lit_config.valgrindArgs, te) - self.executor = te - - def configure_target_info(self): - self.target_info = make_target_info(self) - - def configure_cxx(self): - # Gather various compiler parameters. - cxx = self.get_lit_conf('cxx_under_test') - self.cxx_is_clang_cl = cxx is not None and \ - os.path.basename(cxx) == 'clang-cl.exe' - # If no specific cxx_under_test was given, attempt to infer it as - # clang++. - if cxx is None or self.cxx_is_clang_cl: - clangxx = lit.util.which('clang++', - self.config.environment['PATH']) - if clangxx: - cxx = clangxx - self.lit_config.note( - "inferred cxx_under_test as: %r" % cxx) - elif self.cxx_is_clang_cl: - self.lit_config.fatal('Failed to find clang++ substitution for' - ' clang-cl') - if not cxx: - self.lit_config.fatal('must specify user parameter cxx_under_test ' - '(e.g., --param=cxx_under_test=clang++)') - self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \ - self._configure_clang_cl(cxx) - cxx_type = self.cxx.type - if cxx_type is not None: - assert self.cxx.version is not None - maj_v, min_v, _ = self.cxx.version - self.config.available_features.add(cxx_type) - self.config.available_features.add('%s-%s' % (cxx_type, maj_v)) - self.config.available_features.add('%s-%s.%s' % ( - cxx_type, maj_v, min_v)) - self.cxx.compile_env = dict(os.environ) - # 'CCACHE_CPP2' prevents ccache from stripping comments while - # preprocessing. This is required to prevent stripping of '-verify' - # comments. - self.cxx.compile_env['CCACHE_CPP2'] = '1' - - def _configure_clang_cl(self, clang_path): - assert self.cxx_is_clang_cl - # FIXME: don't hardcode the target - flags = ['--target=i686-pc-windows'] - compile_flags = [] - link_flags = ['-fuse-ld=lld'] - if 'INCLUDE' in os.environ: - compile_flags += ['-isystem %s' % p.strip() - for p in os.environ['INCLUDE'].split(';') - if p.strip()] - if 'LIB' in os.environ: - link_flags += ['-L%s' % p.strip() - for p in os.environ['LIB'].split(';') if p.strip()] - return CXXCompiler(clang_path, flags=flags, - compile_flags=compile_flags, - link_flags=link_flags) - - - def configure_src_root(self): - self.libcxx_src_root = self.get_lit_conf( - 'libcxx_src_root', os.path.dirname(self.config.test_source_root)) - - def configure_obj_root(self): - self.project_obj_root = self.get_lit_conf('project_obj_root') - self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_root') - if not self.libcxx_obj_root and self.project_obj_root is not None: - possible_root = os.path.join(self.project_obj_root, 'projects', 'libcxx') - if os.path.isdir(possible_root): - self.libcxx_obj_root = possible_root - else: - self.libcxx_obj_root = self.project_obj_root - - def configure_cxx_library_root(self): - self.cxx_library_root = self.get_lit_conf('cxx_library_root', - self.libcxx_obj_root) - self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root', - self.cxx_library_root) - - def configure_use_system_cxx_lib(self): - # This test suite supports testing against either the system library or - # the locally built one; the former mode is useful for testing ABI - # compatibility between the current headers and a shipping dynamic - # library. - self.use_system_cxx_lib = self.get_lit_bool('use_system_cxx_lib') - if self.use_system_cxx_lib is None: - # Default to testing against the locally built libc++ library. - self.use_system_cxx_lib = False - self.lit_config.note( - "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib) - - def configure_cxx_stdlib_under_test(self): - self.cxx_stdlib_under_test = self.get_lit_conf( - 'cxx_stdlib_under_test', 'libc++') - if self.cxx_stdlib_under_test not in \ - ['libc++', 'libstdc++', 'cxx_default']: - self.lit_config.fatal( - 'unsupported value for "cxx_stdlib_under_test": %s' - % self.cxx_stdlib_under_test) - self.config.available_features.add(self.cxx_stdlib_under_test) - if self.cxx_stdlib_under_test == 'libstdc++': - self.config.available_features.add('libstdc++') - # Manually enable the experimental and filesystem tests for libstdc++ - # if the options aren't present. - # FIXME this is a hack. - if self.get_lit_conf('enable_experimental') is None: - self.config.enable_experimental = 'true' - if self.get_lit_conf('enable_filesystem') is None: - self.config.enable_filesystem = 'true' - - def configure_use_clang_verify(self): - '''If set, run clang with -verify on failing tests.''' - self.use_clang_verify = self.get_lit_bool('use_clang_verify') - if self.use_clang_verify is None: - # NOTE: We do not test for the -verify flag directly because - # -verify will always exit with non-zero on an empty file. - self.use_clang_verify = self.cxx.isVerifySupported() - if self.use_clang_verify: - self.config.available_features.add('verify-support') - self.lit_config.note( - "inferred use_clang_verify as: %r" % self.use_clang_verify) - - def configure_use_thread_safety(self): - '''If set, run clang with -verify on failing tests.''' - has_thread_safety = self.cxx.hasCompileFlag('-Werror=thread-safety') - if has_thread_safety: - self.cxx.compile_flags += ['-Werror=thread-safety'] - self.config.available_features.add('thread-safety') - self.lit_config.note("enabling thread-safety annotations") - - def configure_execute_external(self): - # Choose between lit's internal shell pipeline runner and a real shell. - # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the - # default value. Otherwise we ask the target_info. - use_lit_shell_default = os.environ.get('LIT_USE_INTERNAL_SHELL') - if use_lit_shell_default is not None: - use_lit_shell_default = use_lit_shell_default != '0' - else: - use_lit_shell_default = self.target_info.use_lit_shell_default() - # Check for the command line parameter using the default value if it is - # not present. - use_lit_shell = self.get_lit_bool('use_lit_shell', - use_lit_shell_default) - self.execute_external = not use_lit_shell - - def configure_ccache(self): - use_ccache_default = os.environ.get('LIBCXX_USE_CCACHE') is not None - use_ccache = self.get_lit_bool('use_ccache', use_ccache_default) - if use_ccache: - self.cxx.use_ccache = True - self.lit_config.note('enabling ccache') - - def configure_features(self): - additional_features = self.get_lit_conf('additional_features') - if additional_features: - for f in additional_features.split(','): - self.config.available_features.add(f.strip()) - self.target_info.add_locale_features(self.config.available_features) - - target_platform = self.target_info.platform() - - # Write an "available feature" that combines the triple when - # use_system_cxx_lib is enabled. This is so that we can easily write - # XFAIL markers for tests that are known to fail with versions of - # libc++ as were shipped with a particular triple. - if self.use_system_cxx_lib: - self.config.available_features.add('with_system_cxx_lib') - self.config.available_features.add( - 'with_system_cxx_lib=%s' % self.config.target_triple) - - # Insert the platform name into the available features as a lower case. - self.config.available_features.add(target_platform) - - # Simulator testing can take a really long time for some of these tests - # so add a feature check so we can REQUIRES: long_tests in them - self.long_tests = self.get_lit_bool('long_tests') - if self.long_tests is None: - # Default to running long tests. - self.long_tests = True - self.lit_config.note( - "inferred long_tests as: %r" % self.long_tests) - - if self.long_tests: - self.config.available_features.add('long_tests') - - # Run a compile test for the -fsized-deallocation flag. This is needed - # in test/std/language.support/support.dynamic/new.delete - if self.cxx.hasCompileFlag('-fsized-deallocation'): - self.config.available_features.add('fsized-deallocation') - - if self.cxx.hasCompileFlag('-faligned-allocation'): - self.config.available_features.add('-faligned-allocation') - else: - # FIXME remove this once more than just clang-4.0 support - # C++17 aligned allocation. - self.config.available_features.add('no-aligned-allocation') - - if self.get_lit_bool('has_libatomic', False): - self.config.available_features.add('libatomic') - - macros = self.cxx.dumpMacros() - if '__cpp_if_constexpr' not in macros: - self.config.available_features.add('libcpp-no-if-constexpr') - - if '__cpp_structured_bindings' not in macros: - self.config.available_features.add('libcpp-no-structured-bindings') - - def configure_compile_flags(self): - no_default_flags = self.get_lit_bool('no_default_flags', False) - if not no_default_flags: - self.configure_default_compile_flags() - # This include is always needed so add so add it regardless of - # 'no_default_flags'. - support_path = os.path.join(self.libcxx_src_root, 'test/support') - self.cxx.compile_flags += ['-I' + support_path] - # 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: - self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS'] - - def configure_default_compile_flags(self): - # Try and get the std version from the command line. Fall back to - # default given in lit.site.cfg is not present. If default is not - # present then force c++11. - std = self.get_lit_conf('std') - if not std: - # Choose the newest possible language dialect if none is given. - possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03'] - if self.cxx.type == 'gcc': - maj_v, _, _ = self.cxx.version - maj_v = int(maj_v) - if maj_v < 7: - possible_stds.remove('c++1z') - # FIXME: How many C++14 tests actually fail under GCC 5 and 6? - # Should we XFAIL them individually instead? - if maj_v <= 6: - possible_stds.remove('c++14') - for s in possible_stds: - if self.cxx.hasCompileFlag('-std=%s' % s): - std = s - self.lit_config.note( - 'inferred language dialect as: %s' % std) - break - if not std: - self.lit_config.fatal( - 'Failed to infer a supported language dialect from one of %r' - % possible_stds) - self.cxx.compile_flags += ['-std={0}'.format(std)] - self.config.available_features.add(std.replace('gnu++', 'c++')) - # Configure include paths - self.configure_compile_flags_header_includes() - self.target_info.add_cxx_compile_flags(self.cxx.compile_flags) - # Configure feature flags. - self.configure_compile_flags_exceptions() - self.configure_compile_flags_rtti() - self.configure_compile_flags_abi_version() - enable_32bit = self.get_lit_bool('enable_32bit', False) - if enable_32bit: - self.cxx.flags += ['-m32'] - # Use verbose output for better errors - self.cxx.flags += ['-v'] - sysroot = self.get_lit_conf('sysroot') - if sysroot: - self.cxx.flags += ['--sysroot', sysroot] - gcc_toolchain = self.get_lit_conf('gcc_toolchain') - if gcc_toolchain: - self.cxx.flags += ['-gcc-toolchain', gcc_toolchain] - if self.use_target: - if not self.cxx.addFlagIfSupported( - ['-target', self.config.target_triple]): - self.lit_config.warning('use_target is true but -target is '\ - 'not supported by the compiler') - - def configure_compile_flags_header_includes(self): - support_path = os.path.join(self.libcxx_src_root, 'test/support') - if self.cxx_stdlib_under_test != 'libstdc++' and \ - not self.is_windows: - self.cxx.compile_flags += [ - '-include', os.path.join(support_path, 'nasty_macros.hpp')] - self.configure_config_site_header() - cxx_headers = self.get_lit_conf('cxx_headers') - if cxx_headers == '' or (cxx_headers is None - and self.cxx_stdlib_under_test != 'libc++'): - self.lit_config.note('using the system cxx headers') - return - self.cxx.compile_flags += ['-nostdinc++'] - if cxx_headers is None: - cxx_headers = os.path.join(self.libcxx_src_root, 'include') - if not os.path.isdir(cxx_headers): - self.lit_config.fatal("cxx_headers='%s' is not a directory." - % cxx_headers) - self.cxx.compile_flags += ['-I' + cxx_headers] - if self.libcxx_obj_root is not None: - cxxabi_headers = os.path.join(self.libcxx_obj_root, 'include', - 'c++-build') - if os.path.isdir(cxxabi_headers): - self.cxx.compile_flags += ['-I' + cxxabi_headers] - - def configure_config_site_header(self): - # Check for a possible __config_site in the build directory. We - # use this if it exists. - if self.libcxx_obj_root is None: - return - config_site_header = os.path.join(self.libcxx_obj_root, '__config_site') - if not os.path.isfile(config_site_header): - return - contained_macros = self.parse_config_site_and_add_features( - config_site_header) - self.lit_config.note('Using __config_site header %s with macros: %r' - % (config_site_header, contained_macros)) - # FIXME: This must come after the call to - # 'parse_config_site_and_add_features(...)' in order for it to work. - self.cxx.compile_flags += ['-include', config_site_header] - - def parse_config_site_and_add_features(self, header): - """ parse_config_site_and_add_features - Deduce and add the test - features that that are implied by the #define's in the __config_site - header. Return a dictionary containing the macros found in the - '__config_site' header. - """ - # Parse the macro contents of __config_site by dumping the macros - # using 'c++ -dM -E' and filtering the predefines. - predefines = self.cxx.dumpMacros() - macros = self.cxx.dumpMacros(header) - feature_macros_keys = set(macros.keys()) - set(predefines.keys()) - feature_macros = {} - for k in feature_macros_keys: - feature_macros[k] = macros[k] - # We expect the header guard to be one of the definitions - assert '_LIBCPP_CONFIG_SITE' in feature_macros - del feature_macros['_LIBCPP_CONFIG_SITE'] - # The __config_site header should be non-empty. Otherwise it should - # have never been emitted by CMake. - assert len(feature_macros) > 0 - # Transform each macro name into the feature name used in the tests. - # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads - for m in feature_macros: - if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS': - continue - if m == '_LIBCPP_ABI_VERSION': - self.config.available_features.add('libcpp-abi-version-v%s' - % feature_macros[m]) - continue - assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE' - m = m.lower()[1:].replace('_', '-') - self.config.available_features.add(m) - return feature_macros - - - - def configure_compile_flags_exceptions(self): - enable_exceptions = self.get_lit_bool('enable_exceptions', True) - if not enable_exceptions: - self.config.available_features.add('libcpp-no-exceptions') - self.cxx.compile_flags += ['-fno-exceptions'] - - def configure_compile_flags_rtti(self): - enable_rtti = self.get_lit_bool('enable_rtti', True) - if not enable_rtti: - self.config.available_features.add('libcpp-no-rtti') - self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI'] - - def configure_compile_flags_abi_version(self): - abi_version = self.get_lit_conf('abi_version', '').strip() - abi_unstable = self.get_lit_bool('abi_unstable') - # Only add the ABI version when it is non-default. - # FIXME(EricWF): Get the ABI version from the "__config_site". - if abi_version and abi_version != '1': - self.cxx.compile_flags += ['-D_LIBCPP_ABI_VERSION=' + abi_version] - if abi_unstable: - self.config.available_features.add('libcpp-abi-unstable') - self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE'] - - def configure_filesystem_compile_flags(self): - enable_fs = self.get_lit_bool('enable_filesystem', default=False) - if not enable_fs: - return - enable_experimental = self.get_lit_bool('enable_experimental', default=False) - if not enable_experimental: - self.lit_config.fatal( - 'filesystem is enabled but libc++experimental.a is not.') - self.config.available_features.add('c++filesystem') - static_env = os.path.join(self.libcxx_src_root, 'test', 'std', - 'experimental', 'filesystem', 'Inputs', 'static_test_env') - static_env = os.path.realpath(static_env) - assert os.path.isdir(static_env) - self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="%s"' % static_env] - - dynamic_env = os.path.join(self.config.test_exec_root, - 'filesystem', 'Output', 'dynamic_env') - dynamic_env = os.path.realpath(dynamic_env) - if not os.path.isdir(dynamic_env): - os.makedirs(dynamic_env) - self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="%s"' % dynamic_env] - self.exec_env['LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env) - - dynamic_helper = os.path.join(self.libcxx_src_root, 'test', 'support', - 'filesystem_dynamic_test_helper.py') - assert os.path.isfile(dynamic_helper) - - self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="%s %s"' - % (sys.executable, dynamic_helper)] - - - def configure_link_flags(self): - no_default_flags = self.get_lit_bool('no_default_flags', False) - if not no_default_flags: - # Configure library path - self.configure_link_flags_cxx_library_path() - self.configure_link_flags_abi_library_path() - - # Configure libraries - if self.cxx_stdlib_under_test == 'libc++': - self.cxx.link_flags += ['-nodefaultlibs'] - # FIXME: Handle MSVCRT as part of the ABI library handling. - if self.is_windows: - self.cxx.link_flags += ['-nostdlib'] - self.configure_link_flags_cxx_library() - self.configure_link_flags_abi_library() - self.configure_extra_library_flags() - elif self.cxx_stdlib_under_test == 'libstdc++': - enable_fs = self.get_lit_bool('enable_filesystem', - default=False) - if enable_fs: - self.config.available_features.add('c++experimental') - self.cxx.link_flags += ['-lstdc++fs'] - self.cxx.link_flags += ['-lm', '-pthread'] - elif self.cxx_stdlib_under_test == 'cxx_default': - self.cxx.link_flags += ['-pthread'] - else: - self.lit_config.fatal( - 'unsupported value for "use_stdlib_type": %s' - % use_stdlib_type) - - link_flags_str = self.get_lit_conf('link_flags', '') - self.cxx.link_flags += shlex.split(link_flags_str) - - def configure_link_flags_cxx_library_path(self): - if not self.use_system_cxx_lib: - if self.cxx_library_root: - self.cxx.link_flags += ['-L' + self.cxx_library_root] - if self.is_windows and self.link_shared: - self.add_path(self.cxx.compile_env, self.cxx_library_root) - if self.cxx_runtime_root: - if not self.is_windows: - self.cxx.link_flags += ['-Wl,-rpath,' + - self.cxx_runtime_root] - elif self.is_windows and self.link_shared: - self.add_path(self.exec_env, self.cxx_runtime_root) - - def configure_link_flags_abi_library_path(self): - # Configure ABI library paths. - self.abi_library_root = self.get_lit_conf('abi_library_path') - if self.abi_library_root: - self.cxx.link_flags += ['-L' + self.abi_library_root] - if not self.is_windows: - self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root] - else: - self.add_path(self.exec_env, self.abi_library_root) - - def configure_link_flags_cxx_library(self): - libcxx_experimental = self.get_lit_bool('enable_experimental', default=False) - if libcxx_experimental: - self.config.available_features.add('c++experimental') - self.cxx.link_flags += ['-lc++experimental'] - if self.link_shared: - self.cxx.link_flags += ['-lc++'] - else: - cxx_library_root = self.get_lit_conf('cxx_library_root') - if cxx_library_root: - libname = self.make_static_lib_name('c++') - abs_path = os.path.join(cxx_library_root, libname) - assert os.path.exists(abs_path) and \ - "static libc++ library does not exist" - self.cxx.link_flags += [abs_path] - else: - self.cxx.link_flags += ['-lc++'] - - def configure_link_flags_abi_library(self): - cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') - if cxx_abi == 'libstdc++': - self.cxx.link_flags += ['-lstdc++'] - elif cxx_abi == 'libsupc++': - self.cxx.link_flags += ['-lsupc++'] - elif cxx_abi == 'libcxxabi': - if self.target_info.allow_cxxabi_link(): - libcxxabi_shared = self.get_lit_bool('libcxxabi_shared', default=True) - if libcxxabi_shared: - self.cxx.link_flags += ['-lc++abi'] - else: - cxxabi_library_root = self.get_lit_conf('abi_library_path') - if cxxabi_library_root: - libname = self.make_static_lib_name('c++abi') - abs_path = os.path.join(cxxabi_library_root, libname) - self.cxx.link_flags += [abs_path] - else: - self.cxx.link_flags += ['-lc++abi'] - elif cxx_abi == 'libcxxrt': - self.cxx.link_flags += ['-lcxxrt'] - elif cxx_abi == 'none' or cxx_abi == 'default': - if self.is_windows: - self.cxx.link_flags += ['-lmsvcrtd'] - else: - self.lit_config.fatal( - 'C++ ABI setting %s unsupported for tests' % cxx_abi) - - def configure_extra_library_flags(self): - if self.get_lit_bool('cxx_ext_threads', default=False): - self.cxx.link_flags += ['-lc++external_threads'] - self.target_info.add_cxx_link_flags(self.cxx.link_flags) - - def configure_color_diagnostics(self): - use_color = self.get_lit_conf('color_diagnostics') - if use_color is None: - use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS') - if use_color is None: - return - if use_color != '': - self.lit_config.fatal('Invalid value for color_diagnostics "%s".' - % use_color) - color_flag = '-fdiagnostics-color=always' - # Check if the compiler supports the color diagnostics flag. Issue a - # warning if it does not since color diagnostics have been requested. - if not self.cxx.hasCompileFlag(color_flag): - self.lit_config.warning( - 'color diagnostics have been requested but are not supported ' - 'by the compiler') - else: - self.cxx.flags += [color_flag] - - def configure_debug_mode(self): - debug_level = self.get_lit_conf('debug_level', None) - if not debug_level: - return - if debug_level not in ['0', '1']: - self.lit_config.fatal('Invalid value for debug_level "%s".' - % debug_level) - self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level] - - def configure_warnings(self): - # Turn on warnings by default for Clang based compilers when C++ >= 11 - default_enable_warnings = self.cxx.type in ['clang', 'apple-clang'] \ - and len(self.config.available_features.intersection( - ['c++11', 'c++14', 'c++1z'])) != 0 - enable_warnings = self.get_lit_bool('enable_warnings', - default_enable_warnings) - if enable_warnings: - self.cxx.useWarnings(True) - self.cxx.warning_flags += [ - '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', - '-Wall', '-Wextra', '-Werror' - ] - self.cxx.addWarningFlagIfSupported('-Wshadow') - self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument') - self.cxx.addWarningFlagIfSupported('-Wno-attributes') - self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move') - self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions') - self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals') - # These warnings should be enabled in order to support the MSVC - # team using the test suite; They enable the warnings below and - # expect the test suite to be clean. - self.cxx.addWarningFlagIfSupported('-Wsign-compare') - self.cxx.addWarningFlagIfSupported('-Wunused-variable') - self.cxx.addWarningFlagIfSupported('-Wunused-parameter') - self.cxx.addWarningFlagIfSupported('-Wunreachable-code') - # FIXME: Enable the two warnings below. - self.cxx.addWarningFlagIfSupported('-Wno-conversion') - self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') - std = self.get_lit_conf('std', None) - if std in ['c++98', 'c++03']: - # The '#define static_assert' provided by libc++ in C++03 mode - # causes an unused local typedef whenever it is used. - self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') - - def configure_sanitizer(self): - san = self.get_lit_conf('use_sanitizer', '').strip() - if san: - self.target_info.add_sanitizer_features(san, self.config.available_features) - # Search for llvm-symbolizer along the compiler path first - # and then along the PATH env variable. - symbolizer_search_paths = os.environ.get('PATH', '') - cxx_path = lit.util.which(self.cxx.path) - if cxx_path is not None: - symbolizer_search_paths = ( - os.path.dirname(cxx_path) + - os.pathsep + symbolizer_search_paths) - llvm_symbolizer = lit.util.which('llvm-symbolizer', - symbolizer_search_paths) - - def add_ubsan(): - self.cxx.flags += ['-fsanitize=undefined', - '-fno-sanitize=vptr,function,float-divide-by-zero', - '-fno-sanitize-recover=all'] - self.exec_env['UBSAN_OPTIONS'] = 'print_stacktrace=1' - self.config.available_features.add('ubsan') - - # Setup the sanitizer compile flags - self.cxx.flags += ['-g', '-fno-omit-frame-pointer'] - if san == 'Address' or san == 'Address;Undefined' or san == 'Undefined;Address': - self.cxx.flags += ['-fsanitize=address'] - if llvm_symbolizer is not None: - self.exec_env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer - # FIXME: Turn ODR violation back on after PR28391 is resolved - # https://llvm.org/bugs/show_bug.cgi?id=28391 - self.exec_env['ASAN_OPTIONS'] = 'detect_odr_violation=0' - self.config.available_features.add('asan') - self.config.available_features.add('sanitizer-new-delete') - self.cxx.compile_flags += ['-O1'] - if san == 'Address;Undefined' or san == 'Undefined;Address': - add_ubsan() - elif san == 'Memory' or san == 'MemoryWithOrigins': - self.cxx.flags += ['-fsanitize=memory'] - if san == 'MemoryWithOrigins': - self.cxx.compile_flags += [ - '-fsanitize-memory-track-origins'] - if llvm_symbolizer is not None: - self.exec_env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer - self.config.available_features.add('msan') - self.config.available_features.add('sanitizer-new-delete') - self.cxx.compile_flags += ['-O1'] - elif san == 'Undefined': - add_ubsan() - self.cxx.compile_flags += ['-O2'] - elif san == 'Thread': - self.cxx.flags += ['-fsanitize=thread'] - self.config.available_features.add('tsan') - self.config.available_features.add('sanitizer-new-delete') - else: - self.lit_config.fatal('unsupported value for ' - 'use_sanitizer: {0}'.format(san)) - san_lib = self.get_lit_conf('sanitizer_library') - if san_lib: - self.cxx.link_flags += [ - san_lib, '-Wl,-rpath,%s' % os.path.dirname(san_lib)] - - def configure_coverage(self): - self.generate_coverage = self.get_lit_bool('generate_coverage', False) - if self.generate_coverage: - self.cxx.flags += ['-g', '--coverage'] - self.cxx.compile_flags += ['-O0'] - - def configure_modules(self): - modules_flags = ['-fmodules'] - if platform.system() != 'Darwin': - modules_flags += ['-Xclang', '-fmodules-local-submodule-visibility'] - supports_modules = self.cxx.hasCompileFlag(modules_flags) - enable_modules_default = supports_modules and \ - os.environ.get('LIBCXX_USE_MODULES') is not None - enable_modules = self.get_lit_bool('enable_modules', - enable_modules_default) - if enable_modules and not supports_modules: - self.lit_config.fatal( - '-fmodules is enabled but not supported by the compiler') - if not supports_modules: - return - self.config.available_features.add('modules-support') - module_cache = os.path.join(self.config.test_exec_root, - 'modules.cache') - module_cache = os.path.realpath(module_cache) - if os.path.isdir(module_cache): - shutil.rmtree(module_cache) - os.makedirs(module_cache) - self.cxx.modules_flags = modules_flags + \ - ['-fmodules-cache-path=' + module_cache] - if enable_modules: - self.config.available_features.add('-fmodules') - self.cxx.useModules() - - def configure_substitutions(self): - sub = self.config.substitutions - # Configure compiler substitutions - sub.append(('%cxx', self.cxx.path)) - # Configure flags substitutions - flags_str = ' '.join(self.cxx.flags) - compile_flags_str = ' '.join(self.cxx.compile_flags) - link_flags_str = ' '.join(self.cxx.link_flags) - all_flags = '%s %s %s' % (flags_str, compile_flags_str, link_flags_str) - sub.append(('%flags', flags_str)) - sub.append(('%compile_flags', compile_flags_str)) - sub.append(('%link_flags', link_flags_str)) - sub.append(('%all_flags', all_flags)) - if self.cxx.isVerifySupported(): - verify_str = ' ' + ' '.join(self.cxx.verify_flags) + ' ' - sub.append(('%verify', verify_str)) - # Add compile and link shortcuts - compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str - + ' ' + compile_flags_str) - link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str + ' ' - + link_flags_str) - assert type(link_str) is str - build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags - if self.cxx.use_modules: - sub.append(('%compile_module', compile_str)) - sub.append(('%build_module', build_str)) - elif self.cxx.modules_flags is not None: - modules_str = ' '.join(self.cxx.modules_flags) + ' ' - sub.append(('%compile_module', compile_str + ' ' + modules_str)) - sub.append(('%build_module', build_str + ' ' + modules_str)) - sub.append(('%compile', compile_str)) - sub.append(('%link', link_str)) - sub.append(('%build', build_str)) - # Configure exec prefix substitutions. - exec_env_str = 'env ' if len(self.exec_env) != 0 else '' - for k, v in self.exec_env.items(): - exec_env_str += ' %s=%s' % (k, v) - # Configure run env substitution. - exec_str = exec_env_str - if self.lit_config.useValgrind: - exec_str = ' '.join(self.lit_config.valgrindArgs) + exec_env_str - sub.append(('%exec', exec_str)) - # Configure run shortcut - sub.append(('%run', exec_str + ' %t.exe')) - # Configure not program substitutions - not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py') - not_str = '%s %s ' % (sys.executable, not_py) - sub.append(('not ', not_str)) - - def configure_triple(self): - # Get or infer the target triple. - self.config.target_triple = self.get_lit_conf('target_triple') - self.use_target = self.get_lit_bool('use_target', False) - if self.use_target and self.config.target_triple: - self.lit_config.warning('use_target is true but no triple is specified') - # If no target triple was given, try to infer it from the compiler - # under test. - if not self.config.target_triple: - target_triple = self.cxx.getTriple() - # Drop sub-major version components from the triple, because the - # current XFAIL handling expects exact matches for feature checks. - # Example: x86_64-apple-darwin14.0.0 -> x86_64-apple-darwin14 - # The 5th group handles triples greater than 3 parts - # (ex x86_64-pc-linux-gnu). - target_triple = re.sub(r'([^-]+)-([^-]+)-([^.]+)([^-]*)(.*)', - r'\1-\2-\3\5', target_triple) - # linux-gnu is needed in the triple to properly identify linuxes - # that use GLIBC. Handle redhat and opensuse triples as special - # cases and append the missing `-gnu` portion. - if (target_triple.endswith('redhat-linux') or - target_triple.endswith('suse-linux')): - target_triple += '-gnu' - self.config.target_triple = target_triple - self.lit_config.note( - "inferred target_triple as: %r" % self.config.target_triple) - - def configure_env(self): - self.target_info.configure_env(self.exec_env) - - def add_path(self, dest_env, new_path): - if 'PATH' not in dest_env: - dest_env['PATH'] = new_path - else: - split_char = ';' if self.is_windows else ':' - dest_env['PATH'] = '%s%s%s' % (new_path, split_char, - dest_env['PATH']) diff --git a/test/libcxx/test/executor.py b/test/libcxx/test/executor.py deleted file mode 100644 index 250186cecb84f..0000000000000 --- a/test/libcxx/test/executor.py +++ /dev/null @@ -1,223 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -import platform -import os - -from libcxx.test import tracing - -from lit.util import executeCommand # pylint: disable=import-error - - -class Executor(object): - def run(self, exe_path, cmd, local_cwd, file_deps=None, env=None): - """Execute a command. - Be very careful not to change shared state in this function. - Executor objects are shared between python processes in `lit -jN`. - Args: - exe_path: str: Local path to the executable to be run - cmd: [str]: subprocess.call style command - local_cwd: str: Local path to the working directory - file_deps: [str]: Files required by the test - env: {str: str}: Environment variables to execute under - Returns: - cmd, out, err, exitCode - """ - raise NotImplementedError - - -class LocalExecutor(Executor): - def __init__(self): - super(LocalExecutor, self).__init__() - self.is_windows = platform.system() == 'Windows' - - def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None): - cmd = cmd or [exe_path] - env_cmd = [] - if env: - env_cmd += ['env'] - env_cmd += ['%s=%s' % (k, v) for k, v in env.items()] - if work_dir == '.': - work_dir = os.getcwd() - if not self.is_windows: - out, err, rc = executeCommand(env_cmd + cmd, cwd=work_dir) - else: - out, err, rc = executeCommand(cmd, cwd=work_dir, - env=self._build_windows_env(env)) - return (env_cmd + cmd, out, err, rc) - - def _build_windows_env(self, exec_env): - # FIXME: Finding Windows DLL's at runtime requires modifying the - # PATH environment variables. However we don't want to print out - # the entire PATH as part of the diagnostic for every failing test. - # Therefore this hack builds a new executable environment that - # merges the current environment and the supplied environment while - # still only printing the supplied environment in diagnostics. - if not self.is_windows or exec_env is None: - return None - new_env = dict(os.environ) - for key, value in exec_env.items(): - if key == 'PATH': - assert value.strip() != '' and "expected non-empty path" - new_env['PATH'] = "%s;%s" % (value, os.environ['PATH']) - else: - new_env[key] = value - return new_env - -class PrefixExecutor(Executor): - """Prefix an executor with some other command wrapper. - - Most useful for setting ulimits on commands, or running an emulator like - qemu and valgrind. - """ - def __init__(self, commandPrefix, chain): - super(PrefixExecutor, self).__init__() - - self.commandPrefix = commandPrefix - self.chain = chain - - def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None): - cmd = cmd or [exe_path] - return self.chain.run(exe_path, self.commandPrefix + cmd, work_dir, - file_deps, env=env) - - -class PostfixExecutor(Executor): - """Postfix an executor with some args.""" - def __init__(self, commandPostfix, chain): - super(PostfixExecutor, self).__init__() - - self.commandPostfix = commandPostfix - self.chain = chain - - def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None): - cmd = cmd or [exe_path] - return self.chain.run(cmd + self.commandPostfix, work_dir, file_deps, - env=env) - - - -class TimeoutExecutor(PrefixExecutor): - """Execute another action under a timeout. - - Deprecated. http://reviews.llvm.org/D6584 adds timeouts to LIT. - """ - def __init__(self, duration, chain): - super(TimeoutExecutor, self).__init__( - ['timeout', duration], chain) - - -class RemoteExecutor(Executor): - def __init__(self): - self.local_run = executeCommand - - def remote_temp_dir(self): - return self._remote_temp(True) - - def remote_temp_file(self): - return self._remote_temp(False) - - def _remote_temp(self, is_dir): - raise NotImplementedError() - - def copy_in(self, local_srcs, remote_dsts): - # This could be wrapped up in a tar->scp->untar for performance - # if there are lots of files to be copied/moved - for src, dst in zip(local_srcs, remote_dsts): - self._copy_in_file(src, dst) - - def _copy_in_file(self, src, dst): - raise NotImplementedError() - - def delete_remote(self, remote): - try: - self._execute_command_remote(['rm', '-rf', remote]) - except OSError: - # TODO: Log failure to delete? - pass - - def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None): - target_exe_path = None - target_cwd = None - try: - target_cwd = self.remote_temp_dir() - target_exe_path = os.path.join(target_cwd, 'libcxx_test.exe') - if cmd: - # Replace exe_path with target_exe_path. - cmd = [c if c != exe_path else target_exe_path for c in cmd] - else: - cmd = [target_exe_path] - - srcs = [exe_path] - dsts = [target_exe_path] - if file_deps is not None: - dev_paths = [os.path.join(target_cwd, os.path.basename(f)) - for f in file_deps] - srcs.extend(file_deps) - dsts.extend(dev_paths) - self.copy_in(srcs, dsts) - # TODO(jroelofs): capture the copy_in and delete_remote commands, - # and conjugate them with '&&'s around the first tuple element - # returned here: - return self._execute_command_remote(cmd, target_cwd, env) - finally: - if target_cwd: - self.delete_remote(target_cwd) - - def _execute_command_remote(self, cmd, remote_work_dir='.', env=None): - raise NotImplementedError() - - -class SSHExecutor(RemoteExecutor): - def __init__(self, host, username=None): - super(SSHExecutor, self).__init__() - - self.user_prefix = username + '@' if username else '' - self.host = host - self.scp_command = 'scp' - self.ssh_command = 'ssh' - - # TODO(jroelofs): switch this on some -super-verbose-debug config flag - if False: - self.local_run = tracing.trace_function( - self.local_run, log_calls=True, log_results=True, - label='ssh_local') - - def _remote_temp(self, is_dir): - # TODO: detect what the target system is, and use the correct - # mktemp command for it. (linux and darwin differ here, and I'm - # sure windows has another way to do it) - - # Not sure how to do suffix on osx yet - dir_arg = '-d' if is_dir else '' - cmd = 'mktemp -q {} /tmp/libcxx.XXXXXXXXXX'.format(dir_arg) - temp_path, err, exitCode = self._execute_command_remote([cmd]) - temp_path = temp_path.strip() - if exitCode != 0: - raise RuntimeError(err) - return temp_path - - def _copy_in_file(self, src, dst): - scp = self.scp_command - remote = self.host - remote = self.user_prefix + remote - cmd = [scp, '-p', src, remote + ':' + dst] - self.local_run(cmd) - - def _execute_command_remote(self, cmd, remote_work_dir='.', env=None): - remote = self.user_prefix + self.host - ssh_cmd = [self.ssh_command, '-oBatchMode=yes', remote] - if env: - env_cmd = ['env'] + ['%s=%s' % (k, v) for k, v in env.items()] - else: - env_cmd = [] - remote_cmd = ' '.join(env_cmd + cmd) - if remote_work_dir != '.': - remote_cmd = 'cd ' + remote_work_dir + ' && ' + remote_cmd - return self.local_run(ssh_cmd + [remote_cmd]) diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py deleted file mode 100644 index cbd96f340bbc2..0000000000000 --- a/test/libcxx/test/format.py +++ /dev/null @@ -1,234 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -import errno -import os -import time -import random - -import lit.Test # pylint: disable=import-error -import lit.TestRunner # pylint: disable=import-error -from lit.TestRunner import ParserKind, IntegratedTestKeywordParser \ - # pylint: disable=import-error -import lit.util # pylint: disable=import-error - - -from libcxx.test.executor import LocalExecutor as LocalExecutor -import libcxx.util - - -class LibcxxTestFormat(object): - """ - Custom test format handler for use with the test format use by libc++. - - Tests fall into two categories: - FOO.pass.cpp - Executable test which should compile, run, and exit with - code 0. - FOO.fail.cpp - Negative test case which is expected to fail compilation. - FOO.sh.cpp - A test that uses LIT's ShTest format. - """ - - def __init__(self, cxx, use_verify_for_fail, execute_external, - executor, exec_env): - self.cxx = cxx.copy() - self.use_verify_for_fail = use_verify_for_fail - self.execute_external = execute_external - self.executor = executor - self.exec_env = dict(exec_env) - - @staticmethod - def _make_custom_parsers(): - return [ - IntegratedTestKeywordParser('FLAKY_TEST.', ParserKind.TAG, - initial_value=False), - IntegratedTestKeywordParser('MODULES_DEFINES:', ParserKind.LIST, - initial_value=[]) - ] - - @staticmethod - def _get_parser(key, parsers): - for p in parsers: - if p.keyword == key: - return p - assert False and "parser not found" - - # TODO: Move this into lit's FileBasedTest - def getTestsInDirectory(self, testSuite, path_in_suite, - litConfig, localConfig): - source_path = testSuite.getSourcePath(path_in_suite) - for filename in os.listdir(source_path): - # Ignore dot files and excluded tests. - if filename.startswith('.') or filename in localConfig.excludes: - continue - - filepath = os.path.join(source_path, filename) - if not os.path.isdir(filepath): - if any([filename.endswith(ext) - for ext in localConfig.suffixes]): - yield lit.Test.Test(testSuite, path_in_suite + (filename,), - localConfig) - - def execute(self, test, lit_config): - while True: - try: - return self._execute(test, lit_config) - except OSError as oe: - if oe.errno != errno.ETXTBSY: - raise - time.sleep(0.1) - - def _execute(self, test, lit_config): - name = test.path_in_suite[-1] - name_root, name_ext = os.path.splitext(name) - is_libcxx_test = test.path_in_suite[0] == 'libcxx' - is_sh_test = name_root.endswith('.sh') - is_pass_test = name.endswith('.pass.cpp') - is_fail_test = name.endswith('.fail.cpp') - assert is_sh_test or name_ext == '.cpp', 'non-cpp file must be sh test' - - if test.config.unsupported: - return (lit.Test.UNSUPPORTED, - "A lit.local.cfg marked this unsupported") - - parsers = self._make_custom_parsers() - script = lit.TestRunner.parseIntegratedTestScript( - test, additional_parsers=parsers, require_script=is_sh_test) - # Check if a result for the test was returned. If so return that - # result. - if isinstance(script, lit.Test.Result): - return script - if lit_config.noExecute: - return lit.Test.Result(lit.Test.PASS) - - # Check that we don't have run lines on tests that don't support them. - if not is_sh_test and len(script) != 0: - lit_config.fatal('Unsupported RUN line found in test %s' % name) - - tmpDir, tmpBase = lit.TestRunner.getTempPaths(test) - substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, - tmpBase) - script = lit.TestRunner.applySubstitutions(script, substitutions) - - test_cxx = self.cxx.copy() - if is_fail_test: - test_cxx.useCCache(False) - test_cxx.useWarnings(False) - extra_modules_defines = self._get_parser('MODULES_DEFINES:', - parsers).getValue() - if '-fmodules' in test.config.available_features: - test_cxx.compile_flags += [('-D%s' % mdef.strip()) for - mdef in extra_modules_defines] - test_cxx.addWarningFlagIfSupported('-Wno-macro-redefined') - # FIXME: libc++ debug tests #define _LIBCPP_ASSERT to override it - # If we see this we need to build the test against uniquely built - # modules. - if is_libcxx_test: - with open(test.getSourcePath(), 'r') as f: - contents = f.read() - if '#define _LIBCPP_ASSERT' in contents: - test_cxx.useModules(False) - - # Dispatch the test based on its suffix. - if is_sh_test: - if not isinstance(self.executor, LocalExecutor): - # We can't run ShTest tests with a executor yet. - # For now, bail on trying to run them - return lit.Test.UNSUPPORTED, 'ShTest format not yet supported' - return lit.TestRunner._runShTest(test, lit_config, - self.execute_external, script, - tmpBase) - elif is_fail_test: - return self._evaluate_fail_test(test, test_cxx, parsers) - elif is_pass_test: - return self._evaluate_pass_test(test, tmpBase, lit_config, - test_cxx, parsers) - else: - # No other test type is supported - assert False - - def _clean(self, exec_path): # pylint: disable=no-self-use - libcxx.util.cleanFile(exec_path) - - def _evaluate_pass_test(self, test, tmpBase, lit_config, - test_cxx, parsers): - execDir = os.path.dirname(test.getExecPath()) - source_path = test.getSourcePath() - exec_path = tmpBase + '.exe' - object_path = tmpBase + '.o' - # Create the output directory if it does not already exist. - lit.util.mkdir_p(os.path.dirname(tmpBase)) - try: - # Compile the test - cmd, out, err, rc = test_cxx.compileLinkTwoSteps( - source_path, out=exec_path, object_file=object_path, - cwd=execDir) - compile_cmd = cmd - if rc != 0: - report = libcxx.util.makeReport(cmd, out, err, rc) - report += "Compilation failed unexpectedly!" - return lit.Test.FAIL, report - # Run the test - local_cwd = os.path.dirname(source_path) - env = None - if self.exec_env: - env = self.exec_env - # TODO: Only list actually needed files in file_deps. - # Right now we just mark all of the .dat files in the same - # directory as dependencies, but it's likely less than that. We - # should add a `// FILE-DEP: foo.dat` to each test to track this. - data_files = [os.path.join(local_cwd, f) - for f in os.listdir(local_cwd) if f.endswith('.dat')] - is_flaky = self._get_parser('FLAKY_TEST.', parsers).getValue() - max_retry = 3 if is_flaky else 1 - for retry_count in range(max_retry): - cmd, out, err, rc = self.executor.run(exec_path, [exec_path], - local_cwd, data_files, - env) - if rc == 0: - res = lit.Test.PASS if retry_count == 0 else lit.Test.FLAKYPASS - return res, '' - elif rc != 0 and retry_count + 1 == max_retry: - report = libcxx.util.makeReport(cmd, out, err, rc) - report = "Compiled With: %s\n%s" % (compile_cmd, report) - report += "Compiled test failed unexpectedly!" - return lit.Test.FAIL, report - - assert False # Unreachable - finally: - # Note that cleanup of exec_file happens in `_clean()`. If you - # override this, cleanup is your reponsibility. - libcxx.util.cleanFile(object_path) - self._clean(exec_path) - - def _evaluate_fail_test(self, test, test_cxx, parsers): - source_path = test.getSourcePath() - # FIXME: lift this detection into LLVM/LIT. - with open(source_path, 'r') as f: - contents = f.read() - verify_tags = ['expected-note', 'expected-remark', 'expected-warning', - 'expected-error', 'expected-no-diagnostics'] - use_verify = self.use_verify_for_fail and \ - any([tag in contents for tag in verify_tags]) - # FIXME(EricWF): GCC 5 does not evaluate static assertions that - # are dependant on a template parameter when '-fsyntax-only' is passed. - # This is fixed in GCC 6. However for now we only pass "-fsyntax-only" - # when using Clang. - if test_cxx.type != 'gcc': - test_cxx.flags += ['-fsyntax-only'] - if use_verify: - test_cxx.useVerify() - cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull) - expected_rc = 0 if use_verify else 1 - if rc == expected_rc: - return lit.Test.PASS, '' - else: - report = libcxx.util.makeReport(cmd, out, err, rc) - report_msg = ('Expected compilation to fail!' if not use_verify else - 'Expected compilation using verify to pass!') - return lit.Test.FAIL, report + report_msg + '\n' diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py deleted file mode 100644 index dc94e7afe0a94..0000000000000 --- a/test/libcxx/test/target_info.py +++ /dev/null @@ -1,224 +0,0 @@ -#===----------------------------------------------------------------------===// -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===// - -import importlib -import lit.util # pylint: disable=import-error,no-name-in-module -import locale -import os -import platform -import sys - -class DefaultTargetInfo(object): - def __init__(self, full_config): - self.full_config = full_config - - def platform(self): - return sys.platform.lower().strip() - - def add_locale_features(self, features): - self.full_config.lit_config.warning( - "No locales entry for target_system: %s" % self.platform()) - - def add_cxx_compile_flags(self, flags): pass - def add_cxx_link_flags(self, flags): pass - def configure_env(self, env): pass - def allow_cxxabi_link(self): return True - def add_sanitizer_features(self, sanitizer_type, features): pass - def use_lit_shell_default(self): return False - - -def test_locale(loc): - assert loc is not None - default_locale = locale.setlocale(locale.LC_ALL) - try: - locale.setlocale(locale.LC_ALL, loc) - return True - except locale.Error: - return False - finally: - locale.setlocale(locale.LC_ALL, default_locale) - - -def add_common_locales(features, lit_config): - # A list of locales needed by the test-suite. - # The list uses the canonical name for the locale used in the test-suite - # TODO: On Linux ISO8859 *may* needs to hyphenated. - locales = [ - 'en_US.UTF-8', - 'fr_FR.UTF-8', - 'ru_RU.UTF-8', - 'zh_CN.UTF-8', - 'fr_CA.ISO8859-1', - 'cs_CZ.ISO8859-2' - ] - for loc in locales: - if test_locale(loc): - features.add('locale.{0}'.format(loc)) - else: - lit_config.warning('The locale {0} is not supported by ' - 'your platform. Some tests will be ' - 'unsupported.'.format(loc)) - - -class DarwinLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(DarwinLocalTI, self).__init__(full_config) - - def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) - - def add_cxx_compile_flags(self, flags): - try: - out = lit.util.capture(['xcrun', '--show-sdk-path']).strip() - res = 0 - except OSError: - res = -1 - if res == 0 and out: - sdk_path = out - self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path) - flags += ["-isysroot", sdk_path] - - def add_cxx_link_flags(self, flags): - flags += ['-lSystem'] - - def configure_env(self, env): - library_paths = [] - # Configure the library path for libc++ - if self.full_config.use_system_cxx_lib: - pass - elif self.full_config.cxx_runtime_root: - library_paths += [self.full_config.cxx_runtime_root] - # Configure the abi library path - if self.full_config.abi_library_root: - library_paths += [self.full_config.abi_library_root] - if library_paths: - env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) - - def allow_cxxabi_link(self): - # FIXME: PR27405 - # libc++ *should* export all of the symbols found in libc++abi on OS X. - # For this reason LibcxxConfiguration will not link libc++abi in OS X. - # However __cxa_throw_bad_new_array_length doesn't get exported into - # libc++ yet so we still need to explicitly link libc++abi when testing - # libc++abi - # See PR22654. - if(self.full_config.get_lit_conf('name', '') == 'libc++abi'): - return True - # Don't link libc++abi explicitly on OS X because the symbols - # should be available in libc++ directly. - return False - - def add_sanitizer_features(self, sanitizer_type, features): - if sanitizer_type == 'Undefined': - features.add('sanitizer-new-delete') - - -class FreeBSDLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(FreeBSDLocalTI, self).__init__(full_config) - - def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) - - def add_cxx_link_flags(self, flags): - flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt'] - - -class LinuxLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(LinuxLocalTI, self).__init__(full_config) - - def platform(self): - return 'linux' - - def platform_name(self): - name, _, _ = platform.linux_distribution() - name = name.lower().strip() - return name # Permitted to be None - - def platform_ver(self): - _, ver, _ = platform.linux_distribution() - ver = ver.lower().strip() - return ver # Permitted to be None. - - def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) - # Some linux distributions have different locale data than others. - # Insert the distributions name and name-version into the available - # features to allow tests to XFAIL on them. - name = self.platform_name() - ver = self.platform_ver() - if name: - features.add(name) - if name and ver: - features.add('%s-%s' % (name, ver)) - - def add_cxx_compile_flags(self, flags): - flags += ['-D__STDC_FORMAT_MACROS', - '-D__STDC_LIMIT_MACROS', - '-D__STDC_CONSTANT_MACROS'] - - def add_cxx_link_flags(self, flags): - enable_threads = ('libcpp-has-no-threads' not in - self.full_config.config.available_features) - llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) - shared_libcxx = self.full_config.get_lit_bool('enable_shared', True) - flags += ['-lm'] - if not llvm_unwinder: - flags += ['-lgcc_s', '-lgcc'] - if enable_threads: - flags += ['-lpthread'] - if not shared_libcxx: - flags += ['-lrt'] - flags += ['-lc'] - if llvm_unwinder: - flags += ['-lunwind', '-ldl'] - else: - flags += ['-lgcc_s'] - flags += ['-lgcc'] - use_libatomic = self.full_config.get_lit_bool('use_libatomic', False) - if use_libatomic: - flags += ['-latomic'] - san = self.full_config.get_lit_conf('use_sanitizer', '').strip() - if san: - # The libraries and their order are taken from the - # linkSanitizerRuntimeDeps function in - # clang/lib/Driver/Tools.cpp - flags += ['-lpthread', '-lrt', '-lm', '-ldl'] - - -class WindowsLocalTI(DefaultTargetInfo): - def __init__(self, full_config): - super(WindowsLocalTI, self).__init__(full_config) - - def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) - - def use_lit_shell_default(self): - # Default to the internal shell on Windows, as bash on Windows is - # usually very slow. - return True - - -def make_target_info(full_config): - default = "libcxx.test.target_info.LocalTI" - info_str = full_config.get_lit_conf('target_info', default) - if info_str != default: - mod_path, _, info = info_str.rpartition('.') - mod = importlib.import_module(mod_path) - target_info = getattr(mod, info)(full_config) - full_config.lit_config.note("inferred target_info as: %r" % info_str) - return target_info - target_system = platform.system() - if target_system == 'Darwin': return DarwinLocalTI(full_config) - if target_system == 'FreeBSD': return FreeBSDLocalTI(full_config) - if target_system == 'Linux': return LinuxLocalTI(full_config) - if target_system == 'Windows': return WindowsLocalTI(full_config) - return DefaultTargetInfo(full_config) - diff --git a/test/libcxx/test/tracing.py b/test/libcxx/test/tracing.py deleted file mode 100644 index c590ba3efd014..0000000000000 --- a/test/libcxx/test/tracing.py +++ /dev/null @@ -1,43 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -import os -import inspect - - -def trace_function(function, log_calls, log_results, label=''): - def wrapper(*args, **kwargs): - kwarg_strs = ['{}={}'.format(k, v) for (k, v) in kwargs] - arg_str = ', '.join([str(a) for a in args] + kwarg_strs) - call_str = '{}({})'.format(function.func_name, arg_str) - - # Perform the call itself, logging before, after, and anything thrown. - try: - if log_calls: - print('{}: Calling {}'.format(label, call_str)) - res = function(*args, **kwargs) - if log_results: - print('{}: {} -> {}'.format(label, call_str, res)) - return res - except Exception as ex: - if log_results: - print('{}: {} raised {}'.format(label, call_str, type(ex))) - raise ex - - return wrapper - - -def trace_object(obj, log_calls, log_results, label=''): - for name, member in inspect.getmembers(obj): - if inspect.ismethod(member): - # Skip meta-functions, decorate everything else - if not member.func_name.startswith('__'): - setattr(obj, name, trace_function(member, log_calls, - log_results, label)) - return obj diff --git a/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp index 6ebba1467db92..62e61818605b0 100644 --- a/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp +++ b/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external +// XFAIL: windows + // <condition_variable> // class condition_variable; diff --git a/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp b/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp deleted file mode 100644 index d3568caa81a38..0000000000000 --- a/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads - -// TODO(EricWF) Investigate why typeid(...).name() returns a different string -// on GCC 4.9 but not newer GCCs. -// XFAIL: gcc-4.9 - -// THIS TESTS C++03 EXTENSIONS. - -// <mutex> - -// template <class ...Mutex> class lock_guard; - -// Test that the the variadic lock guard implementation mangles the same in -// C++11 and C++03. This is important since the mangling of `lock_guard` depends -// on it being declared as a variadic template, even in C++03. - -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#include <mutex> -#include <string> -#include <typeinfo> -#include <cassert> - -int main() { - const std::string expect = "NSt3__110lock_guardIJNS_5mutexEEEE"; - assert(typeid(std::lock_guard<std::mutex>).name() == expect); -} diff --git a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp index c6ed66ce41d9c..1618155008ab1 100644 --- a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp +++ b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external +// XFAIL: windows + // <mutex> // class mutex; diff --git a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp index 2031e4d7d4bbc..f8f4040804297 100644 --- a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp +++ b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external +// XFAIL: windows + // <mutex> // class recursive_mutex; diff --git a/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp index 1b1cbf89a0997..c818474ba9419 100644 --- a/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp +++ b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp @@ -9,6 +9,8 @@ // // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external +// XFAIL: windows + // <thread> // class thread diff --git a/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp index e864af7f05b28..e801fc46a9e1c 100644 --- a/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp +++ b/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external +// REQUIRES: libcpp-has-thread-api-pthread // <thread> diff --git a/test/libcxx/type_traits/convert_to_integral.pass.cpp b/test/libcxx/type_traits/convert_to_integral.pass.cpp index 3fdc98f5468f4..8cac0c7d82555 100644 --- a/test/libcxx/type_traits/convert_to_integral.pass.cpp +++ b/test/libcxx/type_traits/convert_to_integral.pass.cpp @@ -76,7 +76,7 @@ void check_enum_types() enum enum1 { zero = 0, one = 1 }; -enum enum2 { +enum enum2 : unsigned long { value = std::numeric_limits<unsigned long>::max() }; diff --git a/test/libcxx/util.py b/test/libcxx/util.py deleted file mode 100644 index 8899ffaa4b265..0000000000000 --- a/test/libcxx/util.py +++ /dev/null @@ -1,55 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===----------------------------------------------------------------------===## - -from contextlib import contextmanager -import os -import tempfile - - -def cleanFile(filename): - try: - os.remove(filename) - except OSError: - pass - - -@contextmanager -def guardedTempFilename(suffix='', prefix='', dir=None): - # Creates and yeilds a temporary filename within a with statement. The file - # is removed upon scope exit. - handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir) - os.close(handle) - yield name - cleanFile(name) - - -@contextmanager -def guardedFilename(name): - # yeilds a filename within a with statement. The file is removed upon scope - # exit. - yield name - cleanFile(name) - - -@contextmanager -def nullContext(value): - # yeilds a variable within a with statement. No action is taken upon scope - # exit. - yield value - - -def makeReport(cmd, out, err, rc): - report = "Command: %s\n" % cmd - report += "Exit Code: %d\n" % rc - if out: - report += "Standard Output:\n--\n%s--\n" % out - if err: - report += "Standard Error:\n--\n%s--\n" % err - report += '\n' - return report diff --git a/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h b/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h index 7e7a5fd24a627..f2a5b08da9ac4 100644 --- a/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h +++ b/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h @@ -129,7 +129,7 @@ private: }; //============================================================================== -// DerivedFromBase - A type that derives from it's template argument 'Base' +// DerivedFromBase - A type that derives from its template argument 'Base' template <class Base> struct DerivedFromType : public Base { DerivedFromType() : Base() {} @@ -138,7 +138,7 @@ struct DerivedFromType : public Base { }; //============================================================================== -// DerefToType - A type that dereferences to it's template argument 'To'. +// DerefToType - A type that dereferences to its template argument 'To'. // The cv-ref qualifiers of the 'DerefToType' object do not propagate // to the resulting 'To' object. template <class To> @@ -154,7 +154,7 @@ struct DerefToType { }; //============================================================================== -// DerefPropToType - A type that dereferences to it's template argument 'To'. +// DerefPropToType - A type that dereferences to its template argument 'To'. // The cv-ref qualifiers of the 'DerefPropToType' object propagate // to the resulting 'To' object. template <class To> diff --git a/test/libcxx/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp b/test/libcxx/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp new file mode 100644 index 0000000000000..319a78b0506ce --- /dev/null +++ b/test/libcxx/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that UBSAN doesn't generate unsigned integer overflow diagnostics +// from within the hashing internals. + +#include <utility> +#include <cstdint> +#include <limits> +#include <string> + +#include "test_macros.h" + +typedef std::__murmur2_or_cityhash<uint32_t> Hash32; +typedef std::__murmur2_or_cityhash<uint64_t> Hash64; + +void test(const void* key, int len) { + for (int i=1; i <= len; ++i) { + Hash32 h1; + Hash64 h2; + DoNotOptimize(h1(key, i)); + DoNotOptimize(h2(key, i)); + } +} + +int main() { + const std::string TestCases[] = { + "abcdaoeuaoeclaoeoaeuaoeuaousaotehu]+}sthoasuthaoesutahoesutaohesutaoeusaoetuhasoetuhaoseutaoseuthaoesutaohes" + "00000000000000000000000000000000000000000000000000000000000000000000000", + "1237546895+54+4554985416849484213464984765465464654564565645645646546456546546" + }; + const size_t NumCases = sizeof(TestCases)/sizeof(TestCases[0]); + for (size_t i=0; i < NumCases; ++i) + test(TestCases[i].data(), TestCases[i].length()); +} diff --git a/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp new file mode 100644 index 0000000000000..e3e083bfb1e99 --- /dev/null +++ b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 + +// <type_traits> + +// template <class T> struct is_aggregate; +// template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value; + +#include <type_traits> + +int main () +{ +#ifdef _LIBCPP_HAS_NO_IS_AGGREGATE + // This should not compile when _LIBCPP_HAS_NO_IS_AGGREGATE is defined. + bool b = __is_aggregate(void); + ((void)b); +#else +#error Forcing failure... +#endif +} 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 a35dfd6962592..c18822bbe8117 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 @@ -30,4 +30,11 @@ int main() { // bind rvalue to constructed non-rvalue std::tuple<std::string &&> t2("hello"); // expected-note {{requested here}} std::tuple<std::string &&> t3(std::allocator_arg, alloc, "hello"); // expected-note {{requested here}} + + // 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}} + } } diff --git a/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp index cb17dfeb071a9..26556c6eb047b 100644 --- a/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp +++ b/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp @@ -12,7 +12,7 @@ // The following compilers don't generate constexpr special members correctly. // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> diff --git a/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp index 286a623882fef..fb6907dc56278 100644 --- a/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp +++ b/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp @@ -12,7 +12,7 @@ // The following compilers don't generate constexpr special members correctly. // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> diff --git a/test/lit.cfg b/test/lit.cfg index eee17fdaa1c84..c54f0a01047c5 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -3,7 +3,7 @@ import os import site -site.addsitedir(os.path.dirname(__file__)) +site.addsitedir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'utils')) # Tell pylint that we know config and lit_config exist somewhere. diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 0cccffcf5ec08..72dcc3aefda3d 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -26,7 +26,7 @@ config.executor = "@LIBCXX_EXECUTOR@" config.llvm_unwinder = "@LIBCXXABI_USE_LLVM_UNWINDER@" config.has_libatomic = "@LIBCXX_HAS_ATOMIC_LIB@" config.use_libatomic = "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@" - +config.debug_build = "@LIBCXX_DEBUG_BUILD@" config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" config.cxx_ext_threads = "@LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@" diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp index e24598a9bc127..e2abf7cce42e7 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <algorithm> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<RandomAccessIterator Iter> // requires ShuffleIterator<Iter> diff --git a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp index c923d847f11e7..313b6bac402ea 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <algorithm> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand> // requires ShuffleIterator<Iter> diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp index de3f0a741045f..1cf2d9e845620 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp @@ -21,6 +21,8 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class InIter, class OutIter> void test() @@ -28,8 +30,8 @@ test() int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa]; - OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::equal_to<int>(), 2)); + OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), + OutIter(ib), equalToTwo); assert(base(r) == ib + sa-3); assert(ib[0] == 0); assert(ib[1] == 1); diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp index 1eff3d39e20e8..f2ffece12e8b0 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp @@ -23,6 +23,8 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class InIter, class OutIter> void test() @@ -30,8 +32,8 @@ test() int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa] = {0}; - OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::equal_to<int>(), 2), 5); + OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), + OutIter(ib), equalToTwo, 5); assert(base(r) == ib + sa); assert(ib[0] == 0); assert(ib[1] == 1); diff --git a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp index 8d6ab04e14ddc..ebb2945d7c434 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp @@ -22,13 +22,15 @@ #include "test_iterators.h" +bool equalToTwo(int v) { return v == 2; } + template <class Iter> void test() { int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); - std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5); + std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5); assert(ia[0] == 0); assert(ia[1] == 1); assert(ia[2] == 5); diff --git a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp index 68556fd988175..6c5e621e4b20a 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp @@ -21,6 +21,8 @@ #include "test_iterators.h" +int plusOne(int v) { return v + 1; } + template <class InIter, class OutIter> void test() @@ -28,8 +30,8 @@ test() int ia[] = {0, 1, 2, 3, 4}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[sa] = {0}; - OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib), - std::bind2nd(std::plus<int>(), 1)); + OutIter r = std::transform(InIter(ia), InIter(ia+sa), + OutIter(ib), plusOne); assert(base(r) == ib + sa); assert(ib[0] == 1); assert(ib[1] == 2); diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp index 025bc06a618da..0a05c6f659ca3 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp @@ -20,17 +20,24 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),2)) == 3); + eq(2)) == 3); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),7)) == 0); + eq(7)) == 0); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia), - std::bind2nd(std::equal_to<int>(),2)) == 0); + eq(2)) == 0); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp index bde6ff389d0cd..c942d2e38a58c 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp @@ -20,16 +20,22 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 3)); + eq(3)); assert(*r == 3); r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 10)); + eq(10)); assert(r == input_iterator<const int*>(ia+s)); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp index 661e643f07d14..e68344b4b259e 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp @@ -20,16 +20,23 @@ #include "test_iterators.h" +struct ne { + ne (int val) : v(val) {} + bool operator () (int v2) const { return v != v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 3)); + ne(3)); assert(*r == 3); r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 10)); + ne(10)); assert(r == input_iterator<const int*>(ia+s)); } diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp index 9da9356b0be1d..082cad5f2d08e 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp @@ -15,14 +15,17 @@ // make_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); assert(std::is_heap(ia, ia+N)); delete [] ia; diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp index 9d0545f0d9c50..01183d16c927e 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> #include <memory> +#include <random> #include <cassert> #include "test_macros.h" @@ -29,6 +30,7 @@ struct indirect_less {return *x < *y;} }; +std::mt19937 randomness; void test(int N) { @@ -36,7 +38,7 @@ void test(int N) { for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); assert(std::is_heap(ia, ia+N, std::greater<int>())); } @@ -64,7 +66,7 @@ void test(int N) // Random { binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>())); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::ref(pred)); assert(pred.count() <= 3u*N); assert(std::is_heap(ia, ia+N, pred)); @@ -90,7 +92,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); assert(std::is_heap(ia, ia+N, indirect_less())); delete [] ia; diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp index 252fc758cb1f8..8ba0f7194062c 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp @@ -15,14 +15,17 @@ // pop_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); for (int i = N; i > 0; --i) { diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp index 0bfad61961ed4..8e7931f7ea5d8 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp @@ -16,10 +16,12 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> + struct indirect_less { template <class P> @@ -29,12 +31,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); for (int i = N; i > 0; --i) { @@ -55,7 +59,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); for (int i = N; i > 0; --i) { diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp index d82896d6a916a..38d7a425d82b0 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp @@ -16,14 +16,17 @@ // push_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp index 5d2985cc07fa6..38d09ceda6e2f 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -30,12 +31,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i, std::greater<int>()); @@ -54,7 +57,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); for (int i = 0; i <= N; ++i) { std::push_heap(ia, ia+i, indirect_less()); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp index c6eaa8ccec865..003138099f5a1 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp @@ -15,14 +15,17 @@ // sort_heap(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N); std::sort_heap(ia, ia+N); assert(std::is_sorted(ia, ia+N)); diff --git a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp index 1c072c5a12ca0..c0a05e4209b35 100644 --- a/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp @@ -16,6 +16,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <memory> @@ -29,12 +30,14 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test(int N) { int* ia = new int [N]; for (int i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, std::greater<int>()); std::sort_heap(ia, ia+N, std::greater<int>()); assert(std::is_sorted(ia, ia+N, std::greater<int>())); @@ -56,7 +59,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int> [N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::make_heap(ia, ia+N, indirect_less()); std::sort_heap(ia, ia+N, indirect_less()); assert(std::is_sorted(ia, ia+N, indirect_less())); diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp index 33a42a2f62a10..683b07d32089e 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp @@ -16,6 +16,7 @@ // inplace_merge(Iter first, Iter middle, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" @@ -42,6 +43,8 @@ struct S { }; #endif +std::mt19937 randomness; + template <class Iter> void test_one(unsigned N, unsigned M) @@ -51,7 +54,7 @@ test_one(unsigned N, unsigned M) value_type* ia = new value_type[N]; for (unsigned i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M); std::sort(ia+M, ia+N); std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N)); diff --git a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp index fd9e5f13c26a4..3d8902ec22715 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" @@ -58,6 +59,8 @@ struct S { #include "test_iterators.h" #include "counting_predicates.hpp" +std::mt19937 randomness; + template <class Iter> void test_one(unsigned N, unsigned M) @@ -67,7 +70,7 @@ test_one(unsigned N, unsigned M) value_type* ia = new value_type[N]; for (unsigned i = 0; i < N; ++i) ia[i] = i; - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M, std::greater<value_type>()); std::sort(ia+M, ia+N, std::greater<value_type>()); binary_counting_predicate<std::greater<value_type>, value_type, value_type> pred((std::greater<value_type>())); @@ -130,7 +133,7 @@ int main() std::unique_ptr<int>* ia = new std::unique_ptr<int>[N]; for (int i = 0; i < N; ++i) ia[i].reset(new int(i)); - std::random_shuffle(ia, ia+N); + std::shuffle(ia, ia+N, randomness); std::sort(ia, ia+M, indirect_less()); std::sort(ia+M, ia+N, indirect_less()); std::inplace_merge(ia, ia+M, ia+N, indirect_less()); diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp index 2a20cac0b79b0..777461023e7d3 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp @@ -19,10 +19,13 @@ // merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class InIter1, class InIter2, class OutIter> void test() @@ -53,7 +56,7 @@ test() int* ic = new int[2*N]; for (unsigned i = 0; i < 2*N; ++i) ic[i] = i; - std::random_shuffle(ic, ic+2*N); + std::shuffle(ic, ic+2*N, randomness); std::copy(ic, ic+N, ia); std::copy(ic+N, ic+2*N, ib); std::sort(ia, ia+N); diff --git a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp index 152c552381b97..3daaeebbeae94 100644 --- a/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp @@ -22,11 +22,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_iterators.h" #include "counting_predicates.hpp" +std::mt19937 randomness; + template <class InIter1, class InIter2, class OutIter> void test() @@ -61,7 +64,7 @@ test() int* ic = new int[2*N]; for (unsigned i = 0; i < 2*N; ++i) ic[i] = i; - std::random_shuffle(ic, ic+2*N); + std::shuffle(ic, ic+2*N, randomness); std::copy(ic, ic+N, ia); std::copy(ic+N, ic+2*N, ib); std::sort(ia, ia+N, std::greater<int>()); diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp index e9cd086ab13d7..471b08cc6e1f1 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp @@ -15,10 +15,13 @@ // max_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -40,7 +43,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp index e60e156455f31..95c7dee2cdb7c 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -42,7 +45,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp index c41884220857e..7cd41eaeae46e 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp @@ -15,10 +15,13 @@ // min_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -40,7 +43,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp index c4c6e31eb6dd7..402d57dae69e8 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -42,7 +45,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp index c2805a656137f..acede6ff7b56c 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp @@ -15,10 +15,13 @@ // minmax_element(Iter first, Iter last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -46,7 +49,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } @@ -66,7 +69,7 @@ test() int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N)); assert(base(p.first) == a); assert(base(p.second) == a+N-1); diff --git a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp index 7840638f742c9..ff83d7e55d3da 100644 --- a/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp @@ -16,11 +16,14 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_macros.h" #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test(Iter first, Iter last) @@ -50,7 +53,7 @@ test(int N) int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = i; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); test(Iter(a), Iter(a+N)); delete [] a; } @@ -70,7 +73,7 @@ test() int* a = new int[N]; for (int i = 0; i < N; ++i) a[i] = 5; - std::random_shuffle(a, a+N); + std::shuffle(a, a+N, randomness); typedef std::greater<int> Compare; Compare comp; std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp); diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp index 560bc902b4828..b43d88fe0cc6e 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp @@ -16,8 +16,11 @@ // nth_element(Iter first, Iter nth, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test_one(int N, int M) { @@ -26,7 +29,7 @@ test_one(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::nth_element(array, array+M, array+N); assert(array[M] == M); std::nth_element(array, array+N, array+N); // begin, end, end diff --git a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp index f2c962724f09f..88249ed78d278 100644 --- a/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <functional> #include <vector> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test_one(int N, int M) { @@ -40,7 +43,7 @@ test_one(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::nth_element(array, array+M, array+N, std::greater<int>()); assert(array[M] == N-M-1); std::nth_element(array, array+N, array+N, std::greater<int>()); // begin, end, end diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp index 1d4ca9925a86c..d0b41cca3ca69 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp @@ -18,10 +18,13 @@ // partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last); #include <algorithm> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test_larger_sorts(int N, int M) @@ -30,7 +33,7 @@ test_larger_sorts(int N, int M) int* output = new int[M]; for (int i = 0; i < N; ++i) input[i] = i; - std::random_shuffle(input, input+N); + std::shuffle(input, input+N, randomness); int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M); int* e = output + std::min(N, M); assert(r == e); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp index 460ea4c082758..0ac2a86afce62 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp @@ -21,10 +21,13 @@ #include <algorithm> #include <functional> +#include <random> #include <cassert> #include "test_iterators.h" +std::mt19937 randomness; + template <class Iter> void test_larger_sorts(int N, int M) @@ -33,7 +36,7 @@ test_larger_sorts(int N, int M) int* output = new int[M]; for (int i = 0; i < N; ++i) input[i] = i; - std::random_shuffle(input, input+N); + std::shuffle(input, input+N, randomness); int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M, std::greater<int>()); int* e = output + std::min(N, M); diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp index 0d32ba898b8f1..05a06a9c33577 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp @@ -16,8 +16,11 @@ // partial_sort(Iter first, Iter middle, Iter last); #include <algorithm> +#include <random> #include <cassert> +std::mt19937 randomness; + void test_larger_sorts(int N, int M) { @@ -26,7 +29,7 @@ test_larger_sorts(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::partial_sort(array, array+M, array+N); for (int i = 0; i < M; ++i) { diff --git a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp index a4fe1cc5e7ca4..847a5829140a7 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <vector> #include <functional> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + void test_larger_sorts(int N, int M) { @@ -40,7 +43,7 @@ test_larger_sorts(int N, int M) int* array = new int[N]; for (int i = 0; i < N; ++i) array[i] = i; - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::partial_sort(array, array+M, array+N, std::greater<int>()); for (int i = 0; i < M; ++i) { diff --git a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp index 689433f9e45ba..6149a574b2301 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp @@ -17,8 +17,11 @@ #include <algorithm> #include <iterator> +#include <random> #include <cassert> +std::mt19937 randomness; + template <class RI> void test_sort_helper(RI f, RI l) @@ -92,7 +95,7 @@ test_larger_sorts(int N, int M) std::sort(array, array+N); assert(std::is_sorted(array, array+N)); // test random pattern - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::sort(array, array+N); assert(std::is_sorted(array, array+N)); // test sorted pattern diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp index 336fcd0b3ddec..994d3a8c4a7c3 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp @@ -17,8 +17,11 @@ #include <algorithm> #include <iterator> +#include <random> #include <cassert> +std::mt19937 randomness; + template <class RI> void test_sort_helper(RI f, RI l) @@ -92,7 +95,7 @@ test_larger_sorts(int N, int M) std::stable_sort(array, array+N); assert(std::is_sorted(array, array+N)); // test random pattern - std::random_shuffle(array, array+N); + std::shuffle(array, array+N, randomness); std::stable_sort(array, array+N); assert(std::is_sorted(array, array+N)); // test sorted pattern diff --git a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp index 49f7122cdb319..347711bf5e3a0 100644 --- a/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp @@ -18,6 +18,7 @@ #include <algorithm> #include <functional> #include <vector> +#include <random> #include <cassert> #include <cstddef> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -32,6 +33,8 @@ struct indirect_less #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +std::mt19937 randomness; + struct first_only { bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y) @@ -59,7 +62,7 @@ void test() } for (int i = 0; i < N - M; i += M) { - std::random_shuffle(v.begin() + i, v.begin() + i + M); + std::shuffle(v.begin() + i, v.begin() + i + M, randomness); } std::stable_sort(v.begin(), v.end(), first_only()); assert(std::is_sorted(v.begin(), v.end())); diff --git a/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp index 32d34d90d7f80..646c6be7da614 100644 --- a/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp +++ b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp @@ -13,7 +13,7 @@ // <map> // Previously this code caused a segfault when compiled at -O2 due to undefined -// behavior in __tree. See https://llvm.org/bugs/show_bug.cgi?id=28469 +// behavior in __tree. See https://bugs.llvm.org/show_bug.cgi?id=28469 #include <functional> #include <map> diff --git a/test/std/containers/associative/map/compare.pass.cpp b/test/std/containers/associative/map/compare.pass.cpp index 9d1c13d7b8e63..8c429cbd3c4b1 100644 --- a/test/std/containers/associative/map/compare.pass.cpp +++ b/test/std/containers/associative/map/compare.pass.cpp @@ -13,8 +13,8 @@ // class Allocator = allocator<pair<const Key, T>>> // class map -// http://llvm.org/bugs/show_bug.cgi?id=16538 -// http://llvm.org/bugs/show_bug.cgi?id=16549 +// https://bugs.llvm.org/show_bug.cgi?id=16538 +// https://bugs.llvm.org/show_bug.cgi?id=16549 #include <map> #include <utility> diff --git a/test/std/containers/associative/map/incomplete_type.pass.cpp b/test/std/containers/associative/map/incomplete_type.pass.cpp index 84c2451ce0872..6acf83129e12c 100644 --- a/test/std/containers/associative/map/incomplete_type.pass.cpp +++ b/test/std/containers/associative/map/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <map> -// Check that std::map and it's iterators can be instantiated with an incomplete +// Check that std::map and its iterators can be instantiated with an incomplete // type. #include <map> diff --git a/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp index 9a00829eadd63..f8fc21f1f2f52 100644 --- a/test/std/containers/associative/map/map.access/index_tuple.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_tuple.pass.cpp @@ -13,7 +13,7 @@ // mapped_type& operator[](const key_type& k); -// http://llvm.org/bugs/show_bug.cgi?id=16542 +// https://bugs.llvm.org/show_bug.cgi?id=16542 #include <map> diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index 817f1207ac949..e06410dcffa23 100644 --- a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -37,14 +37,16 @@ struct some_comp int main() { typedef std::pair<const MoveOnly, MoveOnly> V; +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index a0cf689ed9096..7f563b7cf635a 100644 --- a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -43,8 +43,10 @@ int main() typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index 705fb580487b0..923a2124ece43 100644 --- a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -92,7 +92,6 @@ int main() V(3, 2), }; { - typedef std::pair<const int, double> V; typedef min_allocator<V> A; typedef test_compare<std::less<int> > C; A a; @@ -106,7 +105,6 @@ int main() assert(m.get_allocator() == a); } { - typedef std::pair<const int, double> V; typedef explicit_allocator<V> A; typedef test_compare<std::less<int> > C; A a; diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index 84f115f1958ef..b45e821ad0f9c 100644 --- a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -45,10 +45,12 @@ int main() typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index b5301418e85a3..84a9609742d3c 100644 --- a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -34,19 +34,21 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index 84907945a90ee..c1aa033845ece 100644 --- a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -99,14 +99,16 @@ int main() typedef std::map<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -129,11 +131,12 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::map<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/multimap/incomplete_type.pass.cpp b/test/std/containers/associative/multimap/incomplete_type.pass.cpp index c461eb38139d5..306f3d9761f17 100644 --- a/test/std/containers/associative/multimap/incomplete_type.pass.cpp +++ b/test/std/containers/associative/multimap/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <map> -// Check that std::multimap and it's iterators can be instantiated with an incomplete +// Check that std::multimap and its iterators can be instantiated with an incomplete // type. #include <map> diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index 6f97a5f3e7567..6020334ed26b8 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -37,14 +37,16 @@ struct some_comp int main() { typedef std::pair<const MoveOnly, MoveOnly> V; +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index 669d23db57cdc..2486e8f243cf7 100644 --- a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -43,8 +43,10 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index 7637885c81e1e..549c1210b6f25 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -45,10 +45,12 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index e42251527eb31..fdcdffbedb4bd 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -34,19 +34,21 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp index df46d376e0280..9e67f97f9ac07 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp @@ -183,7 +183,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef std::pair<M::iterator, M::iterator> R; diff --git a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp index f5295e52d1923..474b7b6ac59cc 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp @@ -147,7 +147,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp index 8a650fa559759..28ff332542b43 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp @@ -155,7 +155,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp index 05760dc0e7513..4f4b3884f28e4 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp @@ -155,7 +155,6 @@ int main() #endif #if TEST_STD_VER > 11 { - typedef std::pair<const int, double> V; typedef std::multimap<int, double, std::less<>> M; typedef M::iterator R; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index ecc9c7ef5fd42..8148ea5b27ed6 100644 --- a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -99,14 +99,16 @@ int main() typedef std::multimap<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -129,10 +131,11 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::multimap<MoveOnly, MoveOnly, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/multiset/incomplete_type.pass.cpp b/test/std/containers/associative/multiset/incomplete_type.pass.cpp index 0355e18f9f296..aecd77a18367d 100644 --- a/test/std/containers/associative/multiset/incomplete_type.pass.cpp +++ b/test/std/containers/associative/multiset/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <set> -// Check that std::multiset and it's iterators can be instantiated with an incomplete +// Check that std::multiset and its iterators can be instantiated with an incomplete // type. #include <set> diff --git a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp index 15520e7834ff7..3156003232db0 100644 --- a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp @@ -36,14 +36,16 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp index b4b9d067704b1..096696fcd94cc 100644 --- a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp index bae97cf4e48a9..18d64bc5f2c88 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp @@ -44,10 +44,12 @@ int main() typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp index 69759e03a28a1..eab1787ec8814 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp @@ -34,18 +34,20 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp index 89fabef0a3a0a..9693ffb15903e 100644 --- a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp @@ -98,14 +98,16 @@ int main() typedef std::multiset<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -128,10 +130,11 @@ int main() typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::multiset<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/associative/set/incomplete_type.pass.cpp b/test/std/containers/associative/set/incomplete_type.pass.cpp index d3a1d6638d7ec..a200223051c82 100644 --- a/test/std/containers/associative/set/incomplete_type.pass.cpp +++ b/test/std/containers/associative/set/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <set> -// Check that std::set and it's iterators can be instantiated with an incomplete +// Check that std::set and its iterators can be instantiated with an incomplete // type. #include <set> diff --git a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp index 6293c24a43d3f..d32cc3f48fef8 100644 --- a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp @@ -36,14 +36,16 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp index 041f599c1f767..c91038e39040f 100644 --- a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp index ce44b69fe3365..c07d4e6f9b881 100644 --- a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp @@ -44,10 +44,12 @@ int main() typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp index 9a7538ca31bd5..901fdbdb321ce 100644 --- a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp @@ -34,18 +34,20 @@ struct some_comp int main() { +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp index b3edd31f749b1..38b0ab8151aa0 100644 --- a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp @@ -98,14 +98,16 @@ int main() typedef std::set<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -128,11 +130,12 @@ int main() typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for comp typedef std::set<MoveOnly, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp index c79feb93eb6ca..5dec2b910fb71 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp @@ -25,8 +25,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::priority_queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp index 43045893fe075..781d740161287 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp index c8becb3ca98a2..58c8f9ddfad19 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::queue<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp index 2d1f9437fc45a..2e217c545f9cc 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::stack<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp index c34b7e07000e0..af6793f465a25 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp @@ -24,8 +24,10 @@ int main() { +#if defined(_LIBCPP_VERSION) { typedef std::stack<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/array/array.size/size.pass.cpp b/test/std/containers/sequences/array/array.size/size.pass.cpp index a833fdc047151..2fe5355124ae2 100644 --- a/test/std/containers/sequences/array/array.size/size.pass.cpp +++ b/test/std/containers/sequences/array/array.size/size.pass.cpp @@ -14,6 +14,8 @@ #include <array> #include <cassert> +#include "test_macros.h" + // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" @@ -36,7 +38,7 @@ int main() assert(c.max_size() == 0); assert(c.empty()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { typedef double T; typedef std::array<T, 3> C; diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index 8e7ff6dff7028..efec4e403001b 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -25,7 +25,7 @@ #if TEST_STD_VER > 14 constexpr bool check_idx( size_t idx, double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.at(idx) == val; } diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp index 239fda5c99d8f..68fc6cdc45435 100644 --- a/test/std/containers/sequences/array/front_back.pass.cpp +++ b/test/std/containers/sequences/array/front_back.pass.cpp @@ -25,13 +25,13 @@ #if TEST_STD_VER > 14 constexpr bool check_front( double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.front() == val; } constexpr bool check_back( double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr.back() == val; } diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp index 6cb7941d92c5a..3a5b9ee9727d9 100644 --- a/test/std/containers/sequences/array/indexing.pass.cpp +++ b/test/std/containers/sequences/array/indexing.pass.cpp @@ -25,7 +25,7 @@ #if TEST_STD_VER > 14 constexpr bool check_idx( size_t idx, double val ) -{ +{ std::array<double, 3> arr = {1, 2, 3.5}; return arr[idx] == val; } diff --git a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp index dea6492a515d8..fdb751da6aafa 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d; d.assign({3, 4, 5, 6}); @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp index 30cca929da11f..e79e6eca3d95a 100644 --- a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp index 59955157421db..288810089e595 100644 --- a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp index dbf27053a9f9f..dd70cda1845bf 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -27,7 +28,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -36,6 +36,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp index 9be3c63a6b312..2619569e154ea 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); @@ -29,7 +30,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -39,6 +39,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp index 68875139da1aa..6e935a52bb24c 100644 --- a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(deque&&); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -51,7 +52,6 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } -#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -67,6 +67,4 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp index 4aa0fa6827e79..5a9a77c746fcb 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque(deque&& c, const allocator_type& a); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -66,7 +67,6 @@ int main() assert(c3.get_allocator() == A(3)); assert(c1.size() != 0); } -#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -82,6 +82,4 @@ int main() assert(c3.get_allocator() == A()); assert(c1.size() == 0); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp index ed8f1544bc8ff..8a65bc2d2e842 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque& operator=(deque&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -69,7 +70,6 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A(5)); } -#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); @@ -86,6 +86,4 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp index 9b813ce342a3c..6ea72246fa058 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp index e0669dc70ca9c..fdf67d23a12d9 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp index 597f642db3ce5..117e942895bad 100644 --- a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // deque& operator=(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d; d = {3, 4, 5, 6}; @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp index 64b3d811fdc9d..de7894234df33 100644 --- a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp @@ -68,7 +68,6 @@ test3(unsigned n, Allocator const &alloc = Allocator()) { #if TEST_STD_VER > 11 typedef std::deque<T, Allocator> C; - typedef typename C::const_iterator const_iterator; { C d(n, alloc); assert(d.size() == n); diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp index 5f7804023c7fe..6d33424fe4103 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::deque<int> d(10, 1); std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -59,5 +60,4 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp index b5c881064a953..060d83b5e2543 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void push_back(value_type&& v); @@ -19,7 +21,6 @@ #include "MoveOnly.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class C> C @@ -57,24 +58,19 @@ void test(int size) } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) test<std::deque<MoveOnly> >(rng[j]); } -#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); for (int j = 0; j < N; ++j) test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp index 8e734a639344f..df3d2d099c708 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void push_front(value_type&& v); @@ -18,7 +20,6 @@ #include "MoveOnly.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class C> C @@ -66,11 +67,9 @@ testN(int start, int N) test(c1, -10); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -78,7 +77,6 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<MoveOnly> >(rng[i], rng[j]); } -#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -86,6 +84,4 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp index c0af762fb2777..0db30a0312829 100644 --- a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::deque<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp index d4dda02b84130..69fb6eb4ca4da 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // void assign(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -42,7 +43,6 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -65,6 +65,4 @@ int main() assert(*i == 10+n); assert(n == 4); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp index 935284831d075..61118353dfb21 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list& operator=(forward_list&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -159,7 +160,6 @@ int main() assert(c1.get_allocator() == A(10)); assert(c0.empty()); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -194,6 +194,4 @@ int main() assert(c1.get_allocator() == A()); assert(c0.empty()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp index 3d35916ccacb9..84f1eb9963fd7 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list& operator=(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -42,7 +43,6 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -65,6 +65,4 @@ int main() assert(*i == 10+n); assert(n == 4); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp index 0ec1f80562a8d..57f09d7cefebd 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp index f70119e3c2afa..4d295d662da1a 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp index ac73d142a67e6..7575c0e812423 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -28,7 +29,6 @@ int main() assert(*i == n); assert(n == 10); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -38,6 +38,4 @@ int main() assert(*i == n); assert(n == 10); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp index 844be20015dd2..cf9cbffa7304c 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(initializer_list<value_type> il, const allocator_type& a); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef test_allocator<T> A; @@ -31,7 +32,6 @@ int main() assert(n == 10); assert(c.get_allocator() == A(14)); } -#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; @@ -43,6 +43,4 @@ int main() assert(n == 10); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index a5948b9ef7997..92a9e39fc94b1 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(forward_list&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -52,7 +53,6 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A(10)); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -68,6 +68,4 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 6a1afe1334b03..5f5f5d0aef600 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // forward_list(forward_list&& x, const allocator_type& a); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef test_allocator<T> A; @@ -33,7 +34,7 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(c0.empty()); assert(c.get_allocator() == A(10)); } @@ -48,11 +49,10 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(!c0.empty()); assert(c.get_allocator() == A(9)); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; @@ -64,10 +64,8 @@ int main() unsigned n = 0; for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) assert(*i == n); - assert(n == std::end(t) - std::begin(t)); + assert(n == static_cast<unsigned>(std::end(t) - std::begin(t))); assert(c0.empty()); assert(c.get_allocator() == A()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp index 5f278e31c0dec..d4fe2591898a5 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp index 089f6d6807cbb..3390c331e00e2 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp deleted file mode 100644 index 2d963a1be4794..0000000000000 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <forward_list> - -// explicit forward_list(size_type n); - -#include <forward_list> -#include <cassert> - -#include "DefaultOnly.h" - -int main() -{ - { - typedef DefaultOnly T; - typedef std::forward_list<T> C; - unsigned N = 10; - C c = N; - unsigned n = 0; - for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(*i == T()); -#else - ; -#endif - assert(n == N); - } -} diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index b536ccf4910eb..061dd6da0785d 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -36,6 +36,11 @@ void check_allocator(unsigned n, Allocator const &alloc = Allocator()) int main() { + { // test that the ctor is explicit + typedef std::forward_list<DefaultOnly> C; + static_assert((std::is_constructible<C, size_t>::value), ""); + static_assert((!std::is_convertible<size_t, C>::value), ""); + } { typedef DefaultOnly T; typedef std::forward_list<T> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp index dd8ea88c2c1aa..8d7c4e9893a2f 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // template <class... Args> @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef Emplaceable T; typedef std::forward_list<T> C; @@ -52,7 +53,6 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } -#if TEST_STD_VER >= 11 { typedef Emplaceable T; typedef std::forward_list<T, min_allocator<T>> C; @@ -84,6 +84,4 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp index 15e1a08b08bf1..90ee0d2313ff3 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // iterator insert_after(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { typedef int T; typedef std::forward_list<T> C; @@ -44,7 +45,6 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -70,6 +70,4 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp index 2e21cc79d2699..173ccaa62d9f5 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // iterator insert_after(const_iterator p, value_type&& v); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -52,7 +53,6 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -85,6 +85,4 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp index d831ceb289189..545b0e68a24bf 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp @@ -32,7 +32,7 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -45,8 +45,6 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -60,7 +58,6 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -73,6 +70,5 @@ int main() c.pop_front(); assert(distance(c.begin(), c.end()) == 0); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp index dfcd2cf90ebcd..7fc2b9d765676 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // void push_front(value_type&& v); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; typedef std::forward_list<T> C; @@ -32,7 +33,6 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; @@ -45,6 +45,4 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp index 65512e317cea0..397f209f72262 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp @@ -15,10 +15,13 @@ #include <iterator> #include <algorithm> #include <vector> +#include <random> #include <cassert> #include "min_allocator.h" +std::mt19937 randomness; + template <class C> void test(int N) { @@ -27,7 +30,7 @@ void test(int N) V v; for (int i = 0; i < N; ++i) v.push_back(i); - std::random_shuffle(v.begin(), v.end()); + std::shuffle(v.begin(), v.end(), randomness); C c(v.begin(), v.end()); c.sort(); assert(distance(c.begin(), c.end()) == N); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp index 6e5cce39e67d2..ab6ae6bd327b0 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp @@ -16,10 +16,13 @@ #include <algorithm> #include <vector> #include <functional> +#include <random> #include <cassert> #include "min_allocator.h" +std::mt19937 randomness; + template <class C> void test(int N) { @@ -28,7 +31,7 @@ void test(int N) V v; for (int i = 0; i < N; ++i) v.push_back(i); - std::random_shuffle(v.begin(), v.end()); + std::shuffle(v.begin(), v.end(), randomness); C c(v.begin(), v.end()); c.sort(std::greater<T>()); assert(distance(c.begin(), c.end()) == N); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp index c63194f7ee64f..d93c079e15edb 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::forward_list<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/list/incomplete_type.pass.cpp b/test/std/containers/sequences/list/incomplete_type.pass.cpp index adfb4d45fc81d..aff8f03678938 100644 --- a/test/std/containers/sequences/list/incomplete_type.pass.cpp +++ b/test/std/containers/sequences/list/incomplete_type.pass.cpp @@ -9,7 +9,7 @@ // <list> -// Check that std::list and it's iterators can be instantiated with an incomplete +// Check that std::list and its iterators can be instantiated with an incomplete // type. #include <list> diff --git a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp index 9b2c6d68cbe54..4704cf40aafa0 100644 --- a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d; d.assign({3, 4, 5, 6}); @@ -29,7 +30,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); @@ -40,6 +40,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp index 2f863c6169fc6..eec214205178f 100644 --- a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list& operator=(list&& c); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -62,7 +63,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -77,6 +77,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp index 6f76d8c568826..7f3114d6e1c48 100644 --- a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp @@ -32,14 +32,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp index 66e40a30d1f10..b5ec50637ab8c 100644 --- a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp index 40413203bdfc4..8f04e7342fc6e 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -28,7 +29,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -38,6 +38,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp index 6040c648e5479..3388e00dfb031 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); @@ -30,7 +31,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -41,6 +41,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp index 9f8a536b33c5a..7236f7cc6ac23 100644 --- a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(list&& c, const allocator_type& a); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -59,7 +60,6 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -73,6 +73,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == min_allocator<MoveOnly>()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp index 81f78116af2e9..0d3ccfa68c931 100644 --- a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp @@ -42,12 +42,14 @@ int main() typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable<C>::value, ""); + static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp index b40cb718a3f16..878dab66f0ad0 100644 --- a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp @@ -32,18 +32,20 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp index 1097bdab21989..b638e219d9c87 100644 --- a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list& operator=(initializer_list<value_type> il); @@ -17,7 +19,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d; d = {3, 4, 5, 6}; @@ -28,7 +29,6 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -39,6 +39,4 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp index 95cdeb0c85393..cbe790c0f3bc5 100644 --- a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp @@ -25,7 +25,6 @@ test3(unsigned n, Allocator const &alloc = Allocator()) { #if TEST_STD_VER > 11 typedef std::list<T, Allocator> C; - typedef typename C::const_iterator const_iterator; { C d(n, alloc); assert(d.size() == n); diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp index 91845e564b023..2d5231e782091 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::list<int> d(10, 1); std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6}); @@ -40,7 +41,6 @@ int main() assert(*i++ == 1); assert(*i++ == 1); } -#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d(10, 1); std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6}); @@ -62,6 +62,4 @@ int main() assert(*i++ == 1); assert(*i++ == 1); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp index 10acede511f4d..3d9d00abe52f5 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void push_back(value_type&& x); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly> l1; l1.push_back(MoveOnly(1)); @@ -30,7 +31,6 @@ int main() assert(l1.front() == MoveOnly(1)); assert(l1.back() == MoveOnly(2)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_back(MoveOnly(1)); @@ -41,6 +41,4 @@ int main() assert(l1.front() == MoveOnly(1)); assert(l1.back() == MoveOnly(2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp index 5321ee0faed3e..6fef6ade9c79a 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void push_front(value_type&& x); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly> l1; l1.push_front(MoveOnly(1)); @@ -30,7 +31,6 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_front(MoveOnly(1)); @@ -41,6 +41,4 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp index 512635359c5d2..cfe1bfd2f411d 100644 --- a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -59,14 +59,16 @@ int main() typedef std::list<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::list<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::list<MoveOnly, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp index ac7a2ce38adfa..60146a88b3b5d 100644 --- a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void assign(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d.assign({true, false, false, true}); @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d.assign({true, false, false, true}); @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp index f07c1d90059dd..13cd65f33123a 100644 --- a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -61,7 +62,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -76,6 +76,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp index 4f860dabac952..4e71df37421eb 100644 --- a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp @@ -31,14 +31,16 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, other_allocator<bool>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp index b8ff33c5d2e85..5f1f5d10485d7 100644 --- a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp @@ -41,8 +41,10 @@ int main() typedef std::vector<bool, other_allocator<bool>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc<bool>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp index ccdce913c73cd..8a1ed033488a3 100644 --- a/test/std/containers/sequences/vector.bool/emplace.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace.pass.cpp @@ -34,7 +34,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.front() == false); @@ -56,7 +56,7 @@ int main() assert(c.front() == false); assert(c.back() == true); - i = c.emplace(c.cbegin()+1, 1 == 1); + i = c.emplace(c.cbegin()+1, true); assert(i == c.begin()+1); assert(c.size() == 3); assert(c.size() == 3); diff --git a/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp new file mode 100644 index 0000000000000..f8a8dbd8d6d4b --- /dev/null +++ b/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <vector> + +// Test that <vector> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <vector> + +#include "poisoned_hash_helper.hpp" +#include "min_allocator.h" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::vector<bool> >(); + test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>(); + } +} diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp index ffe844e0079c2..d5c3f458c6347 100644 --- a/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -12,7 +12,7 @@ // std::find with vector<bool>::iterator -// http://llvm.org/bugs/show_bug.cgi?id=16816 +// https://bugs.llvm.org/show_bug.cgi?id=16816 #include <vector> #include <algorithm> diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp index 07bae0eb70897..a850fa2f1cdd2 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d = {true, false, false, true}; assert(d.size() == 4); @@ -27,7 +28,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d = {true, false, false, true}; assert(d.size() == 4); @@ -36,6 +36,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp index 5f7f5144f8413..9a2df4290e771 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3)); assert(d.get_allocator() == test_allocator<bool>(3)); @@ -29,7 +30,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>()); assert(d.get_allocator() == min_allocator<bool>()); @@ -39,6 +39,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp index 3a176d94e860e..df4cb199b8fd4 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d(10, true); std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -39,7 +40,6 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d(10, true); std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); @@ -60,6 +60,4 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp index f3a11ec562c0d..f189e2b97092b 100644 --- a/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -45,7 +46,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -59,6 +59,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp index 7aaa7c55550b2..b3b6f964966b5 100644 --- a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c, const allocator_type& a); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); @@ -58,7 +59,6 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<bool>(4)); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); @@ -72,6 +72,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == min_allocator<bool>()); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index dd4bf9e01ea9e..556b6e6564393 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -59,31 +59,40 @@ struct some_alloc3 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<bool, test_allocator<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_assignable<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); #endif } #if TEST_STD_VER > 14 +#if defined(_LIBCPP_VERSION) { // POCMA false, is_always_equal true typedef std::vector<bool, some_alloc2<bool>> C; - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_assignable<C>::value, ""); + static_assert( std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { // POCMA false, is_always_equal false typedef std::vector<bool, some_alloc3<bool>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index 3305d95e1ab86..f104eb32e5f4d 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -31,24 +31,29 @@ struct some_alloc int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; // In C++17, move constructors for allocators are not allowed to throw #if TEST_STD_VER > 14 - LIBCPP_STATIC_ASSERT( std::is_nothrow_move_constructible<C>::value, ""); +#if defined(_LIBCPP_VERSION) + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( std::is_nothrow_move_constructible<C>::value, ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif } diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp index 4b959cf00ad34..61874338d6551 100644 --- a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<bool> d; d = {true, false, false, true}; @@ -28,7 +29,6 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d = {true, false, false, true}; @@ -38,6 +38,4 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp index 1b68eda2757bf..d888af05f92f1 100644 --- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -55,32 +55,39 @@ struct some_alloc2 int main() { +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, test_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::vector<bool, other_allocator<bool>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { - typedef std::vector<bool, some_alloc<bool>> C; #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) // In c++14, if POCS is set, swapping the allocator is required not to throw - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + typedef std::vector<bool, some_alloc<bool>> C; + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); +#endif // _LIBCPP_VERSION #else + typedef std::vector<bool, some_alloc<bool>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); #endif } #if TEST_STD_VER >= 14 +#if defined(_LIBCPP_VERSION) { typedef std::vector<bool, some_alloc2<bool>> C; // if the allocators are always equal, then the swap can be noexcept - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp index 4f82792fa1fde..64104a40ec743 100644 --- a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -31,7 +31,8 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); - + ASSERT_NOEXCEPT(H()(T())); + bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; @@ -43,6 +44,7 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp index 6409acaf65c19..273bdad9acdb1 100644 --- a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "MoveOnly.h" #include "min_allocator.h" @@ -20,9 +22,8 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { - std::vector<MoveOnly> v(100); + std::vector<int> v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -34,7 +35,7 @@ int main() } { // Add 1 for implementations that dynamically allocate a container proxy. - std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100); + std::vector<int, limited_allocator<int, 300 + 1> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -44,9 +45,9 @@ int main() assert(v.capacity() >= 200); assert(is_contiguous_container_asan_correct(v)); } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { - std::vector<int> v(100); + std::vector<MoveOnly> v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -58,7 +59,7 @@ int main() } { // Add 1 for implementations that dynamically allocate a container proxy. - std::vector<int, limited_allocator<int, 300 + 1> > v(100); + std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); @@ -68,8 +69,6 @@ int main() assert(v.capacity() >= 200); assert(is_contiguous_container_asan_correct(v)); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> v(100); v.resize(50); diff --git a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp index 222fa9c78f921..853f75583ddc6 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void assign(initializer_list<value_type> il); @@ -20,7 +22,6 @@ template <typename Vec> void test ( Vec &v ) { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS v.assign({3, 4, 5, 6}); assert(v.size() == 4); assert(is_contiguous_container_asan_correct(v)); @@ -28,7 +29,6 @@ void test ( Vec &v ) assert(v[1] == 4); assert(v[2] == 5); assert(v[3] == 6); -#endif } int main() @@ -41,8 +41,6 @@ int main() test(d1); test(d2); } - -#if TEST_STD_VER >= 11 { typedef std::vector<int, min_allocator<int>> V; V d1; @@ -51,5 +49,4 @@ int main() test(d1); test(d2); } -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp index acbee97bcd1c5..c2b6b83784f24 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(vector&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -76,7 +77,6 @@ int main() assert(l2.get_allocator() == lo.get_allocator()); assert(is_contiguous_container_asan_correct(l2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -96,6 +96,4 @@ int main() assert(l2.get_allocator() == lo.get_allocator()); assert(is_contiguous_container_asan_correct(l2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp index 10a381f9c8cc4..1720866940ede 100644 --- a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp index 408bcc3b14990..edbad8c0d95b7 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il); @@ -18,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -28,7 +29,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); @@ -38,6 +38,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp index f4c3b5c1e8e0a..ac5d0178e73a5 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); @@ -31,7 +32,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); @@ -42,6 +42,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp index d51b364f3ba0b..cd50d54323490 100644 --- a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -68,7 +69,6 @@ int main() assert(*j == 3); assert(is_contiguous_container_asan_correct(c2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -98,6 +98,4 @@ int main() assert(*j == 3); assert(is_contiguous_container_asan_correct(c2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp index fcdd35ae1157e..767a0ce3dce9a 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector(vector&& c, const allocator_type& a); @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -75,7 +76,6 @@ int main() assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); assert(is_contiguous_container_asan_correct(l2)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -94,6 +94,4 @@ int main() assert(l2.get_allocator() == min_allocator<MoveOnly>()); assert(is_contiguous_container_asan_correct(l2)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp index 4e5a204136839..21dd5c384b586 100644 --- a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // vector& operator=(initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d; d = {3, 4, 5, 6}; @@ -30,7 +31,6 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d; d = {3, 4, 5, 6}; @@ -41,6 +41,4 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp new file mode 100644 index 0000000000000..5f053eb8565a7 --- /dev/null +++ b/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <vector> + +// void clear(); + +#include <vector> +#include <cassert> + +#include "min_allocator.h" +#include "asan_testing.h" + +int main() +{ + { + int a[] = {1, 2, 3}; + std::vector<int> c(a, a+3); + c.clear(); + assert(c.empty()); + LIBCPP_ASSERT(c.__invariants()); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + } +#if TEST_STD_VER >= 11 + { + int a[] = {1, 2, 3}; + std::vector<int, min_allocator<int>> c(a, a+3); + c.clear(); + assert(c.empty()); + LIBCPP_ASSERT(c.__invariants()); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); + } +#endif +} diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp index 7e4aed8c1b5e8..e5e0277fa37a6 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // template <class... Args> iterator emplace(const_iterator pos, Args&&... args); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> v; v.reserve(3); @@ -38,7 +39,6 @@ int main() assert(v[0] == 3); assert(is_contiguous_container_asan_correct(v)); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; v.reserve(3); @@ -57,6 +57,4 @@ int main() assert(v[0] == 3); assert(is_contiguous_container_asan_correct(v)); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp index b0fe123aac480..9072d427cab79 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // iterator insert(const_iterator p, initializer_list<value_type> il); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS { std::vector<int> d(10, 1); std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -41,7 +42,6 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d(10, 1); std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); @@ -63,6 +63,4 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#endif -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp index f4a1f5d5f519c..ac1fffd9d0d77 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void push_back(value_type&& x); @@ -21,7 +23,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::vector<MoveOnly> c; c.push_back(MoveOnly(0)); @@ -81,7 +82,6 @@ int main() for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j) assert(c[j] == MoveOnly(j)); } -#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> c; c.push_back(MoveOnly(0)); @@ -110,6 +110,4 @@ int main() for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j) assert(c[j] == MoveOnly(j)); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp index 214f9a5775711..f92ab8a5c3005 100644 --- a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -60,10 +60,12 @@ int main() typedef std::vector<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); diff --git a/test/std/containers/unord/unord.map/compare.pass.cpp b/test/std/containers/unord/unord.map/compare.pass.cpp index ea6d02f5fcbc0..cffc1dbd42c12 100644 --- a/test/std/containers/unord/unord.map/compare.pass.cpp +++ b/test/std/containers/unord/unord.map/compare.pass.cpp @@ -13,8 +13,8 @@ // class Alloc = allocator<pair<const Key, T>>> // class unordered_map -// http://llvm.org/bugs/show_bug.cgi?id=16538 -// http://llvm.org/bugs/show_bug.cgi?id=16549 +// https://bugs.llvm.org/show_bug.cgi?id=16538 +// https://bugs.llvm.org/show_bug.cgi?id=16549 #include <unordered_map> #include <cassert> diff --git a/test/std/containers/unord/unord.map/incomplete_type.pass.cpp b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp index d51b1d8d181f6..9fc0fd471ef5f 100644 --- a/test/std/containers/unord/unord.map/incomplete_type.pass.cpp +++ b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp @@ -10,7 +10,7 @@ // <unordered_map> -// Check that std::unordered_map and it's iterators can be instantiated with an incomplete +// Check that std::unordered_map and its iterators can be instantiated with an incomplete // type. #include <unordered_map> diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp index 939e0bcd4e69a..7ef7f47ff865a 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,23 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp index 4fb10afd4e595..0fe98abe774dc 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,8 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +55,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp index c0dc71da45d84..4191102a85abe 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,8 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +56,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp index c40173ede7505..2eb8c946720f6 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,28 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp index f2c694e86f74c..400e0283fef2d 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp @@ -17,7 +17,7 @@ // mapped_type& operator[](const key_type& k); -// http://llvm.org/bugs/show_bug.cgi?id=16542 +// https://bugs.llvm.org/show_bug.cgi?id=16542 #include <unordered_map> #include <tuple> diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp index fc286ceec8eb6..75807fa78889c 100644 --- a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp @@ -64,6 +64,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; template <class T> @@ -72,6 +73,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(T const&) const; }; #if TEST_STD_VER >= 14 @@ -125,16 +127,18 @@ int main() typedef std::unordered_map<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MapType>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MapType>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +182,11 @@ int main() typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MapType>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_map<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MapType>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp index 4eea3d0f6fb5e..5cb60f6a6d91d 100644 --- a/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; typedef std::pair<int, std::string> P; P a[] = { diff --git a/test/std/containers/unord/unord.multimap/incomplete.pass.cpp b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp index 7822224e7366d..67bff94197572 100644 --- a/test/std/containers/unord/unord.multimap/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp @@ -10,7 +10,7 @@ // <unordered_map> -// Check that std::unordered_multimap and it's iterators can be instantiated with an incomplete +// Check that std::unordered_multimap and its iterators can be instantiated with an incomplete // type. #include <unordered_map> diff --git a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp index 9c42435946ffa..ff3bc0105bd3b 100644 --- a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp @@ -44,7 +44,6 @@ int main() } { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } @@ -70,7 +69,6 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp index a2ab399d34697..3e9a10ab798a1 100644 --- a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp @@ -25,8 +25,6 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; assert(c.max_bucket_count() > 0); } @@ -34,8 +32,6 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef C::const_iterator I; - typedef std::pair<int, std::string> P; const C c; assert(c.max_bucket_count() > 0); } diff --git a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp index b0b2b664f0988..38c8285f52363 100644 --- a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp @@ -30,13 +30,11 @@ int main() { { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multimap<int, std::string> C; - typedef std::pair<int, std::string> P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -46,14 +44,12 @@ int main() { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; - typedef std::pair<int, std::string> P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp index 0f898f1b73e01..8c5ddab054e57 100644 --- a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp @@ -34,7 +34,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -219,7 +218,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -404,7 +402,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp index e404612a754e2..d924ef15c1a3a 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp index b5f4403174b89..2fbe7a6742731 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp index b621449f2b740..2d5766946a6fe 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp index 94067c3161e24..7f3a337bddc4c 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 7a58709c9fc97..33d8e3c36361e 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -64,6 +64,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; template <class T> @@ -72,6 +73,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(T const&) const; }; #if TEST_STD_VER >= 14 @@ -124,16 +126,18 @@ int main() typedef std::unordered_multimap<MoveOnly, MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<V>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -177,9 +181,11 @@ int main() typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<V>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<V>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp index 06e6c65c991d5..644af867dad49 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp @@ -33,7 +33,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -218,7 +217,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -403,7 +401,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<std::pair<const int, std::string> > Alloc; typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C; - typedef std::pair<int, std::string> P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp index ec4d0e675501e..c60a811678fbb 100644 --- a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_multiset<int> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multiset<int> C; - typedef C::const_iterator I; typedef int P; P a[] = { @@ -52,15 +49,12 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; typedef int P; P a[] = { diff --git a/test/std/containers/unord/unord.multiset/incomplete.pass.cpp b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp index f6d8dc17c5a2e..1b3c1492c4a48 100644 --- a/test/std/containers/unord/unord.multiset/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp @@ -11,7 +11,7 @@ // <unordered_set> -// Check that std::unordered_multiset and it's iterators can be instantiated with an incomplete +// Check that std::unordered_multiset and its iterators can be instantiated with an incomplete // type. #include <unordered_set> diff --git a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp index fad1c182e6b7f..df2cb7beff394 100644 --- a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp @@ -43,7 +43,6 @@ int main() } { typedef std::unordered_multiset<int> C; - typedef int P; const C c; assert(c.load_factor() == 0); } @@ -69,7 +68,6 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp index 00fe962327f8a..f7ebaaf65d47b 100644 --- a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp @@ -29,13 +29,11 @@ int main() { { typedef std::unordered_multiset<int> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multiset<int> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -45,14 +43,12 @@ int main() { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp index c0c9e90217128..9ffe3ad480be5 100644 --- a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp index fba024aed00ef..3b69c1eed2e38 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp index 62fe51e29903f..1e927b9b3958b 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp index ac0a10a4b0ea1..7336bb5afa7c5 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp index e44be18fa3b49..fcf2a5af31299 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp index c221b6f2edb0e..4afef42e6a60e 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -125,16 +125,18 @@ int main() typedef std::unordered_multiset<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +180,11 @@ int main() typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_multiset<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp index d4efb68680266..ce290ff1c1e70 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_multiset<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.set/bucket_count.pass.cpp b/test/std/containers/unord/unord.set/bucket_count.pass.cpp index 6f1f526abaf6e..227d9e1233312 100644 --- a/test/std/containers/unord/unord.set/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.set/bucket_count.pass.cpp @@ -25,14 +25,11 @@ int main() { { typedef std::unordered_set<int> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_set<int> C; - typedef C::const_iterator I; typedef int P; P a[] = { @@ -51,14 +48,11 @@ int main() #if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; - typedef int P; const C c; LIBCPP_ASSERT(c.bucket_count() == 0); } { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef C::const_iterator I; typedef int P; P a[] = { diff --git a/test/std/containers/unord/unord.set/incomplete.pass.cpp b/test/std/containers/unord/unord.set/incomplete.pass.cpp index c970c1de5531f..4f7a00c999e8a 100644 --- a/test/std/containers/unord/unord.set/incomplete.pass.cpp +++ b/test/std/containers/unord/unord.set/incomplete.pass.cpp @@ -11,7 +11,7 @@ // <unordered_set> -// Check that std::unordered_set and it's iterators can be instantiated with an incomplete +// Check that std::unordered_set and its iterators can be instantiated with an incomplete // type. #include <unordered_set> diff --git a/test/std/containers/unord/unord.set/load_factor.pass.cpp b/test/std/containers/unord/unord.set/load_factor.pass.cpp index a342d472a3d58..94eb5d1bd04be 100644 --- a/test/std/containers/unord/unord.set/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/load_factor.pass.cpp @@ -43,7 +43,6 @@ int main() } { typedef std::unordered_set<int> C; - typedef int P; const C c; assert(c.load_factor() == 0); } @@ -69,7 +68,6 @@ int main() { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp index 542788cca9678..e9e04bca85622 100644 --- a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp @@ -29,13 +29,11 @@ int main() { { typedef std::unordered_set<int> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_set<int> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); @@ -45,14 +43,12 @@ int main() { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; - typedef int P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.set/swap_member.pass.cpp b/test/std/containers/unord/unord.set/swap_member.pass.cpp index ea88c53a526cb..597662112cefe 100644 --- a/test/std/containers/unord/unord.set/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.set/swap_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp index 3dcc3247902ed..b8d06dbfdd161 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp @@ -42,19 +42,22 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); + static_assert(std::is_nothrow_default_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp index 82e184b8d3ea6..4c10ed2d6290b 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp @@ -35,6 +35,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); ~some_hash() noexcept(false); + std::size_t operator()(T const&) const; }; int main() @@ -53,13 +54,15 @@ int main() std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, some_comp<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp index b89d68002477a..670a3484d15fe 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp @@ -41,6 +41,7 @@ struct some_hash some_hash(); some_hash(const some_hash&); some_hash& operator=(const some_hash&); + std::size_t operator()(T const&) const; }; int main() @@ -54,11 +55,13 @@ int main() std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable<C>::value, ""); + static_assert(std::is_nothrow_move_assignable<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp index 7190a01208f04..43e06bd50463a 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp @@ -38,24 +38,27 @@ struct some_hash typedef T value_type; some_hash(); some_hash(const some_hash&); + std::size_t operator()(T const&) const; }; int main() { +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible<C>::value, ""); + static_assert(std::is_nothrow_move_constructible<C>::value, ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp index 4a16ddd3f4ce6..7187f94a28dc7 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -125,16 +125,18 @@ int main() typedef std::unordered_set<MoveOnly> C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C; static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); @@ -178,10 +180,11 @@ int main() typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc2<MoveOnly>> C; static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } - +#if defined(_LIBCPP_VERSION) { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp typedef std::unordered_set<MoveOnly, some_hash2<MoveOnly>, some_comp2<MoveOnly>, some_alloc3<MoveOnly>> C; - LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION #endif } diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp index c2bd75960d5be..9ca2f80f05615 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp @@ -32,7 +32,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef test_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1, 1)); C c2(0, Hash(2), Compare(2), Alloc(1, 2)); c2.max_load_factor(2); @@ -213,7 +212,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef other_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -394,7 +392,6 @@ int main() typedef test_compare<std::equal_to<int> > Compare; typedef min_allocator<int> Alloc; typedef std::unordered_set<int, Hash, Compare, Alloc> C; - typedef int P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp index 2c6acb5af12c5..a5d52a6ef7787 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp index aeea7dec9e34a..cce3c79ef5ba5 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp index 6809073c2d0c5..b83c266fb9b2d 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp index 27ba0e513e45c..10a4326471990 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr& a) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp index e29ff2e782447..3dfd200fafa9c 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp @@ -13,6 +13,8 @@ // explicit auto_ptr(X* p =0) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp index 6f53581af4228..91801efac64a8 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr& operator=(auto_ptr_ref<X> r) throw() +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp index 375780527cf00..e08df64377d5b 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // auto_ptr(auto_ptr_ref<X> r) throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp index 00c0f6d30cafa..572e5e686d49f 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr<Y>() throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp index a5db81e6c6324..cd9fed2fb10e1 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp @@ -13,6 +13,8 @@ // template<class Y> operator auto_ptr_ref<Y>() throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp index fce9332df846a..305cf025ce454 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp index dd5669563e35c..7174b27fb8620 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp @@ -13,6 +13,8 @@ // X& operator*() const throw(); +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <cassert> diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp index 5860eb4111434..650da2ef81961 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include "../A.h" void diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp index cdbdd73ab72d3..55772b68808de 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp @@ -16,6 +16,8 @@ #include <memory> #include <cassert> +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include "../A.h" void diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp index 256563439a177..1895828aff647 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp @@ -17,6 +17,8 @@ // ... // }; +// REQUIRES: c++98 || c++03 || c++11 || c++14 + #include <memory> #include <type_traits> diff --git a/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/test/std/depr/depr.c.headers/stdio_h.pass.cpp index 85f9d2986284f..36c37a3beb3e7 100644 --- a/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -99,7 +99,7 @@ #include <cstdarg> -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic ignored "-Wformat-zero-length" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam #endif @@ -107,7 +107,7 @@ int main() { FILE* fp = 0; - fpos_t fpos = {}; + fpos_t fpos = fpos_t(); size_t s = 0; char* cp = 0; char arr[] = {'a', 'b'}; diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp new file mode 100644 index 0000000000000..fc37c9a59797a --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// pointer_to_binary_function +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double binary_f(int i, short j) {return i - j + .75;} + +int main() +{ + typedef std::pointer_to_binary_function<int, short, double> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp index 41c99998caeb5..e47731a65133d 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // pointer_to_binary_function diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp new file mode 100644 index 0000000000000..687a819a392d7 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// pointer_to_unary_function +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double unary_f(int i) {return 0.5 - i;} + +int main() +{ + typedef std::pointer_to_unary_function<int, double> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp index 126cf32af4364..2d713b3beed20 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // pointer_to_unary_function diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp new file mode 100644 index 0000000000000..2d232193607b5 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template <CopyConstructible Arg, Returnable Result> +// pointer_to_unary_function<Arg, Result> +// ptr_fun(Result (*f)(Arg)); +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +double unary_f(int i) {return 0.5 - i;} + +int main() +{ + assert(std::ptr_fun(unary_f)(36) == -35.5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp index c7ce90df3eb7f..65f2a8d342536 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <CopyConstructible Arg, Returnable Result> // pointer_to_unary_function<Arg, Result> diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp index ed94c1a1e4701..202abe25e0084 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp @@ -7,22 +7,22 @@ // //===----------------------------------------------------------------------===// -// <memory> +// <functional> -// unique_ptr +// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> +// pointer_to_binary_function<Arg1,Arg2,Result> +// ptr_fun(Result (*f)(Arg1, Arg2)); +// UNSUPPORTED: c++98, c++03, c++11, c++14 -// Test unique_ptr move assignment - -#include <memory> +#include <functional> +#include <type_traits> +#include <cassert> #include "test_macros.h" +double binary_f(int i, short j) {return i - j + .75;} + int main() { - std::unique_ptr<int> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member of 'std::__1::unique_ptr}} -#endif + assert(std::ptr_fun(binary_f)(36, 27) == 9.75); } diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp index 17c4b611a319c..5628c026c95a7 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> // pointer_to_binary_function<Arg1,Arg2,Result> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp new file mode 100644 index 0000000000000..1c56aa9f5dc5b --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<cReturnable S, ClassType T> +// const_mem_fun_t<S,T> +// mem_fun(S (T::*f)() const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun(&A::a3)(&a) == 1); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp index 455eed9b3e3ca..4693c816c3383 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<cReturnable S, ClassType T> // const_mem_fun_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp new file mode 100644 index 0000000000000..c727e955b1d5c --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// const_mem_fun1_t<S,T,A> +// mem_fun(S (T::*f)(A) const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun(&A::a4)(&a, 6) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp index 46fd6d28d5145..9f0b605d9a91b 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // const_mem_fun1_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..39b3112da94c9 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun1_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun1_ref_t<double, A, unsigned> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp index 0c4bb93ff524c..65fc8c07eb2ce 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun1_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..f07a3b798e72a --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun1_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun1_t<double, A, unsigned> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp index ca670bcde109e..71588fa1f9d3e 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun1_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp new file mode 100644 index 0000000000000..fea1441b31f1d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// const_mem_fun_ref_t<S,T> +// mem_fun_ref(S (T::*f)() const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun_ref(&A::a3)(a) == 1); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp index 74d8950dea7f1..22f44c65cd6ae 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // const_mem_fun_ref_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp new file mode 100644 index 0000000000000..f993b7ce1949f --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// const_mem_fun1_ref_t<S,T,A> +// mem_fun_ref(S (T::*f)(A) const); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + const A a = A(); + assert(std::mem_fun_ref(&A::a4)(a, 6) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp index b858561ae757c..267b80681eaf7 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // const_mem_fun1_ref_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..e195213f9c02d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun_ref_t<int, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp index 9eec24e5743c9..6f80993cbcdf8 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..228eb3da60a6b --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// const_mem_fun_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::const_mem_fun_t<int, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp index 9681b74d7e612..01945fc46f9f8 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // const_mem_fun_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp new file mode 100644 index 0000000000000..8f59a1ae2f82b --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// mem_fun_t<S,T> +// mem_fun(S (T::*f)()); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun(&A::a1)(&a) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp index d0d286009ada4..f3c12973fc8b3 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // mem_fun_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp new file mode 100644 index 0000000000000..6191de3fbe632 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// mem_fun1_t<S,T,A> +// mem_fun(S (T::*f)(A)); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun(&A::a2)(&a, 5) == 6); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp index acee9afeec7a5..30f3c9422d2bf 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // mem_fun1_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..0effd33f3784d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun1_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun1_ref_t<short, A, int> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp index a78cbf25c191f..0b63bb76ddb7f 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun1_ref_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..aa8e25abe4381 --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun1_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun1_t<short, A, int> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp index 90ba9bbf788db..79895c4b4d899 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun1_t diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp new file mode 100644 index 0000000000000..ff7f28af8e30d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T> +// mem_fun_ref_t<S,T> +// mem_fun_ref(S (T::*f)()); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun_ref(&A::a1)(a) == 5); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp index d3843fc5344c5..8a6a8b943e4b1 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T> // mem_fun_ref_t<S,T> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp new file mode 100644 index 0000000000000..82d47fefd3d4f --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// template<Returnable S, ClassType T, CopyConstructible A> +// mem_fun1_ref_t<S,T,A> +// mem_fun_ref(S (T::*f)(A)); +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + A a; + assert(std::mem_fun_ref(&A::a2)(a, 5) == 6); +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp index 39a324d10bc4b..142b16a6b3e4b 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<Returnable S, ClassType T, CopyConstructible A> // mem_fun1_ref_t<S,T,A> diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp new file mode 100644 index 0000000000000..f1cf01c5c424d --- /dev/null +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// mem_fun_ref_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include <functional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct A +{ + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} +}; + +int main() +{ + typedef std::mem_fun_ref_t<char, A> F; +} diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp index 236d8d0945fb6..5af028b39928f 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun_ref_t diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp index 6e13873c2fb3b..e6a1ed330762a 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp @@ -7,33 +7,27 @@ // //===----------------------------------------------------------------------===// -// <memory> +// <functional> -// unique_ptr +// mem_fun_t +// Removed in c++1z +// UNSUPPORTED: c++98, c++03, c++11, c++14 -// Test unique_ptr move assignment - -#include <memory> -#include <utility> +#include <functional> +#include <type_traits> #include <cassert> -// Can't copy from const lvalue +#include "test_macros.h" struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} + char a1() {return 5;} + short a2(int i) {return short(i+1);} + int a3() const {return 1;} + double a4(unsigned i) const {return i-1;} }; -int A::count = 0; - int main() { - { - const std::unique_ptr<A[]> s(new A[3]); - std::unique_ptr<A[]> s2; - s2 = s; - } + typedef std::mem_fun_t<char, A> F; } diff --git a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp index 3fc84cd05c63b..c33e2f7d753fa 100644 --- a/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp +++ b/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // mem_fun_t diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp index b6b75263c6027..796e4ad878be9 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn, class T> // binder1st<Fn> diff --git a/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp index b7feb243b8391..cbf1dbf9fbd94 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn, class T> // binder2nd<Fn> diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp index 8b7aaf0fdae1a..480148b7658e4 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn> // class binder1st diff --git a/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp index 645c1688c18af..3dfb1f02d2a22 100644 --- a/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp +++ b/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template <class Fn> // class binder2nd diff --git a/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp index 02f9a81aa6ddd..5c596da5a0bcd 100644 --- a/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test get_unexpected #include <exception> diff --git a/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp index ed02fa618e8ee..9b9d726f7f3c0 100644 --- a/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test set_unexpected #include <exception> diff --git a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp index 5879529317ef0..f6bc5bc5a68c1 100644 --- a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp +++ b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test unexpected_handler #include <exception> diff --git a/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp index 03b484f7631a5..92d4d38e272bb 100644 --- a/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp +++ b/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: c++98 || c++03 || c++11 || c++14 + // test unexpected #include <exception> diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp index af7f27f73fc59..8a9a1a232d0dc 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp +++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp @@ -7,23 +7,24 @@ // //===----------------------------------------------------------------------===// -// <memory> +// XFAIL: c++98, c++03 -// unique_ptr +// <system_error> -// Test unique_ptr<T[]>(pointer) ctor +// class error_code -#include <memory> +// explicit operator bool() const; -// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: +#include <system_error> - void operator()(void*) {} -}; +bool test_func(void) +{ + const std::error_code ec(0, std::generic_category()); + return ec; // conversion to bool is explicit; should fail. +} int main() { - std::unique_ptr<int[], Deleter&> p(new int); + return 0; } + diff --git a/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp new file mode 100644 index 0000000000000..f1b4605759176 --- /dev/null +++ b/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <system_error> + +// Test that <system_error> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <system_error> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::error_code>(); + test_hash_enabled_for_type<std::error_condition>(); + } +} diff --git a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp index 4091f446af276..dac13bdb83c87 100644 --- a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp @@ -29,6 +29,7 @@ test(int i) typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; T ec(i, std::system_category()); const std::size_t result = h(ec); diff --git a/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp index d455210c2697f..eef37c68b6f06 100644 --- a/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp @@ -29,6 +29,7 @@ test(int i) typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; T ec(i, std::system_category()); const std::size_t result = h(ec); diff --git a/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp index 531731791c5d0..23098d83e4ea6 100644 --- a/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp +++ b/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp @@ -58,19 +58,23 @@ void test() { const unsigned os = Expectations::os; SampleItem oa[os]; const int *oa1 = Expectations::oa1; + ((void)oa1); // Prevent unused warning const int *oa2 = Expectations::oa2; + ((void)oa2); // Prevent unused warning std::minstd_rand g; SampleIterator end; end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, g); - assert(end.base() - oa == std::min(os, is)); - assert(std::equal(oa, oa + os, oa1)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + // sample() is deterministic but non-reproducible; + // its results can vary between implementations. + LIBCPP_ASSERT(std::equal(oa, oa + os, oa1)); end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, std::move(g)); - assert(end.base() - oa == std::min(os, is)); - assert(std::equal(oa, oa + os, oa2)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); + LIBCPP_ASSERT(std::equal(oa, oa + os, oa2)); } template <template<class...> class PopulationIteratorType, class PopulationItem, @@ -119,7 +123,7 @@ void test_small_population() { end = std::experimental::sample(PopulationIterator(ia), PopulationIterator(ia + is), SampleIterator(oa), os, g); - assert(end.base() - oa == std::min(os, is)); + assert(static_cast<std::size_t>(end.base() - oa) == std::min(os, is)); assert(std::equal(oa, end.base(), oa1)); } diff --git a/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp b/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp index 585b0bb1dd5ee..a744e659f5b5b 100644 --- a/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp +++ b/test/std/experimental/filesystem/class.file_status/file_status.cons.pass.cpp @@ -30,8 +30,8 @@ int main() { { static_assert(std::is_nothrow_default_constructible<file_status>::value, "The default constructor must be noexcept"); - static_assert(!test_convertible<file_status>(), - "The default constructor must be explicit"); + static_assert(test_convertible<file_status>(), + "The default constructor must not be explicit"); const file_status f; assert(f.type() == file_type::none); assert(f.permissions() == perms::unknown); diff --git a/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp index f344e11530718..a6172d1981cf6 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.append.pass.cpp @@ -131,7 +131,7 @@ void doAppendSourceAllocTest(AppendOperatorTestcase const& TC) assert(LHS == E); } // input iterator - For non-native char types, appends needs to copy the - // iterator range into a contigious block of memory before it can perform the + // iterator range into a contiguous block of memory before it can perform the // code_cvt conversions. // For "char" no allocations will be performed because no conversion is // required. diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp index a4bd2cba1cef8..c5da52f652483 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.assign/braced_init.pass.cpp @@ -7,29 +7,26 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03 -// unique_ptr +// <experimental/filesystem> -// Test unique_ptr converting move ctor +// class path -// Do not convert from an array unique_ptr +// path& operator=(path const&); -#include <memory> -#include <utility> +#include <experimental/filesystem> +#include <type_traits> #include <cassert> -struct A -{ -}; +#include "test_macros.h" +#include "count_new.hpp" -struct Deleter -{ - void operator()(void*) {} -}; +namespace fs = std::experimental::filesystem; -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2(std::move(s)); +int main() { + using namespace fs; + path p("abc"); + p = {}; + assert(p.native() == ""); } diff --git a/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp index 9e48cbf1e7f21..8c31ef51d9448 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.assign/source.pass.cpp @@ -15,6 +15,7 @@ // template <class Source> // path& operator=(Source const&); +// path& operator=(string_type&&); // template <class Source> // path& assign(Source const&); // template <class InputIterator> @@ -49,7 +50,7 @@ void RunTestCase(MultiStringType const& MS) { const std::basic_string<CharT> S(TestPath); path p; PathReserve(p, S.length() + 1); { - // string provides a contigious iterator. No allocation needed. + // string provides a contiguous iterator. No allocation needed. DisableAllocationGuard g; path& pref = (p = S); assert(&pref == &p); @@ -75,7 +76,7 @@ void RunTestCase(MultiStringType const& MS) { const std::basic_string_view<CharT> S(TestPath); path p; PathReserve(p, S.length() + 1); { - // string provides a contigious iterator. No allocation needed. + // string provides a contiguous iterator. No allocation needed. DisableAllocationGuard g; path& pref = (p = S); assert(&pref == &p); @@ -101,7 +102,7 @@ void RunTestCase(MultiStringType const& MS) { { path p; PathReserve(p, Size + 1); { - // char* pointers are contigious and can be used with code_cvt directly. + // char* pointers are contiguous and can be used with code_cvt directly. // no allocations needed. DisableAllocationGuard g; path& pref = (p = TestPath); @@ -213,12 +214,29 @@ void test_sfinae() { } } +void RunStringMoveTest(const char* Expect) { + using namespace fs; + std::string ss(Expect); + path p; + { + DisableAllocationGuard g; ((void)g); + path& pr = (p = std::move(ss)); + assert(&pr == &p); + } + assert(p == Expect); + { + // Signature test + ASSERT_NOEXCEPT(p = std::move(ss)); + } +} + int main() { for (auto const& MS : PathList) { RunTestCase<char>(MS); RunTestCase<wchar_t>(MS); RunTestCase<char16_t>(MS); RunTestCase<char32_t>(MS); + RunStringMoveTest(MS); } test_sfinae(); } diff --git a/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp index 89269362d06fe..76df0e9eef76a 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp @@ -132,7 +132,7 @@ void doConcatSourceAllocTest(ConcatOperatorTestcase const& TC) assert(LHS == E); } // input iterator - For non-native char types, appends needs to copy the - // iterator range into a contigious block of memory before it can perform the + // iterator range into a contiguous block of memory before it can perform the // code_cvt conversions. // For "char" no allocations will be performed because no conversion is // required. diff --git a/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp index 4c83481aaf2d8..078e006663e93 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp @@ -54,12 +54,6 @@ #include "count_new.hpp" #include "filesystem_test_helper.hpp" -template <class It> -std::reverse_iterator<It> mkRev(It it) { - return std::reverse_iterator<It>(it); -} - - namespace fs = std::experimental::filesystem; struct PathDecomposeTestcase { @@ -147,7 +141,11 @@ void decompPathTest() assert(checkCollectionsEqual(p.begin(), p.end(), TC.elements.begin(), TC.elements.end())); // check backwards - assert(checkCollectionsEqual(mkRev(p.end()), mkRev(p.begin()), + + std::vector<fs::path> Parts; + for (auto it = p.end(); it != p.begin(); ) + Parts.push_back(*--it); + assert(checkCollectionsEqual(Parts.begin(), Parts.end(), TC.elements.rbegin(), TC.elements.rend())); } } diff --git a/test/std/experimental/filesystem/class.path/synop.pass.cpp b/test/std/experimental/filesystem/class.path/synop.pass.cpp index b0a7b5cd65e21..883feb287d06c 100644 --- a/test/std/experimental/filesystem/class.path/synop.pass.cpp +++ b/test/std/experimental/filesystem/class.path/synop.pass.cpp @@ -32,7 +32,7 @@ int main() { { ASSERT_SAME_TYPE(const path::value_type, decltype(path::preferred_separator)); static_assert(path::preferred_separator == '/', ""); - // Make preferred_separator ODR used by taking it's address. + // Make preferred_separator ODR used by taking its address. const char* dummy = &path::preferred_separator; ((void)dummy); } diff --git a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp index e67fc2f20f6ef..26fc3ca28d8e9 100644 --- a/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp +++ b/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp @@ -175,7 +175,7 @@ TEST_CASE(access_denied_on_recursion_test_case) TEST_CHECK(ec); TEST_CHECK(it == endIt); } - // Same as obove but test operator++(). + // Same as above but test operator++(). { std::error_code ec = GetTestEC(); recursive_directory_iterator it(startDir, ec); @@ -222,7 +222,7 @@ TEST_CASE(access_denied_on_recursion_test_case) TEST_REQUIRE(ec); TEST_REQUIRE(it == endIt); } - // Same as obove but testing the throwing constructors + // Same as above but testing the throwing constructors { TEST_REQUIRE_THROW(filesystem_error, recursive_directory_iterator(permDeniedDir)); diff --git a/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp b/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp index d8d92c5888ac6..447fb46e840b9 100644 --- a/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp +++ b/test/std/experimental/filesystem/fs.filesystem.synopsis/file_time_type.pass.cpp @@ -18,8 +18,8 @@ #include <type_traits> // system_clock is used because it meets the requirements of TrivialClock, -// and it's resolution and range of system_clock should match the operating -// systems file time type. +// and the resolution and range of system_clock should match the operating +// system's file time type. typedef std::chrono::system_clock ExpectedClock; typedef std::chrono::time_point<ExpectedClock> ExpectedTimePoint; diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp index 4d59235c722b8..28e945b689703 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.absolute/absolute.pass.cpp @@ -54,7 +54,7 @@ TEST_CASE(absolute_path_test) TEST_REQUIRE(not p.has_root_name()); TEST_REQUIRE(p.has_root_directory()); TEST_CHECK(p.is_absolute()); - // ensure absolute(base) is not recursivly called + // ensure absolute(base) is not recursively called TEST_REQUIRE(base.has_root_name()); TEST_REQUIRE(base.has_root_directory()); @@ -73,7 +73,7 @@ TEST_CASE(absolute_path_test) TEST_REQUIRE(p.has_root_name()); TEST_REQUIRE(not p.has_root_directory()); TEST_CHECK(not p.is_absolute()); - // absolute is called recursivly on base. The following conditions + // absolute is called recursively on base. The following conditions // must be true for it to return base unmodified TEST_REQUIRE(base.has_root_name()); TEST_REQUIRE(base.has_root_directory()); diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp index 252ced6fd65fa..2b9f57e7e9542 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp @@ -85,4 +85,13 @@ TEST_CASE(test_exists_fails) TEST_CHECK_THROW(filesystem_error, exists(file)); } +TEST_CASE(test_name_too_long) { + std::string long_name(2500, 'a'); + const path file(long_name); + + std::error_code ec; + TEST_CHECK(exists(file, ec) == false); + TEST_CHECK(ec); +} + TEST_SUITE_END() diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp index 4177392141e54..794aeb992640d 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.permissions/permissions.pass.cpp @@ -144,7 +144,7 @@ TEST_CASE(test_no_resolve_symlink_on_symlink) std::error_code expected_ec; #else // On linux symlink permissions are not supported. The error code should - // be 'operation_not_supported' and the sylink permissions should be + // be 'operation_not_supported' and the symlink permissions should be // unchanged. const auto expected_link_perms = symlink_status(sym).permissions(); std::error_code expected_ec = std::make_error_code(std::errc::operation_not_supported); diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp index 2c76caf74c847..fdc3d2b4a61ff 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp @@ -65,29 +65,36 @@ TEST_CASE(test_status_cannot_resolve) const std::error_code set_ec = std::make_error_code(std::errc::address_in_use); - const std::error_code expect_ec = + const std::error_code perm_ec = std::make_error_code(std::errc::permission_denied); + const std::error_code name_too_long_ec = + std::make_error_code(std::errc::filename_too_long); - const path cases[] = { - file, sym + struct TestCase { + path p; + std::error_code expect_ec; + } const TestCases[] = { + {file, perm_ec}, + {sym, perm_ec}, + {path(std::string(2500, 'a')), name_too_long_ec} }; - for (auto& p : cases) + for (auto& TC : TestCases) { { // test non-throwing case std::error_code ec = set_ec; - file_status st = status(p, ec); - TEST_CHECK(ec == expect_ec); + file_status st = status(TC.p, ec); + TEST_CHECK(ec == TC.expect_ec); TEST_CHECK(st.type() == file_type::none); TEST_CHECK(st.permissions() == perms::unknown); } #ifndef TEST_HAS_NO_EXCEPTIONS { // test throwing case try { - status(p); + status(TC.p); } catch (filesystem_error const& err) { - TEST_CHECK(err.path1() == p); + TEST_CHECK(err.path1() == TC.p); TEST_CHECK(err.path2() == ""); - TEST_CHECK(err.code() == expect_ec); + TEST_CHECK(err.code() == TC.expect_ec); } } #endif diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp index 148564e61961e..021dd7fc81608 100644 --- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp +++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp @@ -97,6 +97,14 @@ TEST_CASE(basic_tests) TEST_CHECK(ec == std::make_error_code(std::errc::permission_denied)); TEST_CHECK(ret == ""); + // Set the env variable to point to a non-existent dir + PutEnv(TC.name, TC.p / "does_not_exist"); + ec = GetTestEC(); + ret = temp_directory_path(ec); + TEST_CHECK(ec != GetTestEC()); + TEST_CHECK(ec); + TEST_CHECK(ret == ""); + // Finally erase this env variable UnsetEnv(TC.name); } diff --git a/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp b/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp index a02dcf336960a..3e83173555be0 100644 --- a/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp +++ b/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp @@ -120,7 +120,7 @@ void test_pmr_uses_alloc(Args&&... args) } { // Test that T(std::allocator_arg_t, Alloc const&, Args...) construction - // is prefered when T(Args..., Alloc const&) is also available. + // is preferred when T(Args..., Alloc const&) is also available. using T = UsesAllocatorV3<Alloc, sizeof...(Args)>; assert((doTest<T>(UA_AllocArg, std::forward<Args>(args)...))); } diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp new file mode 100644 index 0000000000000..c8d6c5367d7ef --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool1.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp new file mode 100644 index 0000000000000..a3a2206fba632 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp new file mode 100644 index 0000000000000..1f04580ddabd4 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool3.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd<volatile bool, int>(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp new file mode 100644 index 0000000000000..1f0e8a2b3a2ff --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.bool4.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::gcd<int, const bool>(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index a52b50b391cd3..3f86cfe4c7f06 100644 --- a/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -129,4 +129,11 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2792 + { + auto res = std::experimental::gcd((int64_t)1234, (int32_t)-2147483648); + static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res == 2); + } } diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp new file mode 100644 index 0000000000000..e4c2ed8bf5396 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool1.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp new file mode 100644 index 0000000000000..097b23eae6e43 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp new file mode 100644 index 0000000000000..d5e6300818ccb --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool3.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm<volatile bool, int>(false, 4); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp new file mode 100644 index 0000000000000..d88c490d64bf7 --- /dev/null +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.bool4.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// <numeric> + +// template<class _M, class _N> +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) + +// Remarks: If either M or N is not an integer type, +// or if either is (a possibly cv-qualified) bool, the program is ill-formed. + +#include <experimental/numeric> + + +int main() +{ + std::experimental::lcm<int, const bool>(2, true); +} diff --git a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index e3c109f7447b3..fd463e88e63f6 100644 --- a/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -128,4 +128,12 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2792 + { + auto res1 = std::experimental::lcm((int64_t)1234, (int32_t)-2147483648); + (void) std::experimental::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN + static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res1 == 1324997410816LL); + } } diff --git a/test/std/experimental/string.view/lit.local.cfg b/test/std/experimental/string.view/lit.local.cfg new file mode 100644 index 0000000000000..376dbe7c16ec9 --- /dev/null +++ b/test/std/experimental/string.view/lit.local.cfg @@ -0,0 +1,3 @@ +# Disable all of the filesystem tests if the correct feature is not available. +if 'msvc' in config.available_features: + config.unsupported = True diff --git a/test/std/experimental/string.view/string.view.access/at.pass.cpp b/test/std/experimental/string.view/string.view.access/at.pass.cpp index 7ceaf5ab3d9f3..eaea062987fb3 100644 --- a/test/std/experimental/string.view/string.view.access/at.pass.cpp +++ b/test/std/experimental/string.view/string.view.access/at.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// NOTE: Older versions of clang have a bug where they fail to evalute +// NOTE: Older versions of clang have a bug where they fail to evaluate // string_view::at as a constant expression. // XFAIL: clang-3.4, clang-3.3 diff --git a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp index 0c5170f29cea9..57dff44976bc8 100644 --- a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp +++ b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp @@ -13,7 +13,7 @@ // template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) -// Testing extended function types. The extented function types are those +// Testing extended function types. The extended function types are those // named by INVOKE but that are not actual callable objects. These include // bullets 1-4 of invoke. diff --git a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp index 5df8691ef1f94..1f1b0c3faa5b6 100644 --- a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -89,7 +89,7 @@ int main() { std::FILE* fp = 0; - std::fpos_t fpos = {}; + std::fpos_t fpos = std::fpos_t(); std::size_t s = 0; char* cp = 0; std::va_list va; diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp index ed68279d7b572..3095712b9dbc2 100644 --- a/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp +++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp @@ -12,7 +12,7 @@ // basic_istream<charT,traits>& // ignore(streamsize n = 1, int_type delim = traits::eof()); -// http://llvm.org/bugs/show_bug.cgi?id=16427 +// https://bugs.llvm.org/show_bug.cgi?id=16427 #include <sstream> #include <cassert> diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp index e68fb774335d7..e09c0ed204616 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp @@ -23,6 +23,7 @@ #include <sstream> #include <ios> +#include <type_traits> #include <cctype> #include <cstdint> #include <cassert> @@ -66,11 +67,15 @@ int main() test_octal<uint64_t>("1777777777777777777777"); test_octal< int64_t>("1777777777777777777777"); test_octal<uint64_t>("1777777777777777777777"); - if (sizeof(long) == sizeof(int64_t)) { + + const bool long_is_64 = std::integral_constant<bool, sizeof(long) == sizeof(int64_t)>::value; // avoid compiler warnings + const bool long_long_is_64 = std::integral_constant<bool, sizeof(long long) == sizeof(int64_t)>::value; // avoid compiler warnings + + if (long_is_64) { test_octal< unsigned long>("1777777777777777777777"); test_octal< long>("1777777777777777777777"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_octal< unsigned long long>("1777777777777777777777"); test_octal< long long>("1777777777777777777777"); } @@ -81,11 +86,11 @@ int main() test_dec< int32_t>( "-1"); test_dec<uint64_t>("18446744073709551615"); test_dec< int64_t>( "-1"); - if (sizeof(long) == sizeof(int64_t)) { + if (long_is_64) { test_dec<unsigned long>("18446744073709551615"); test_dec< long>( "-1"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_dec<unsigned long long>("18446744073709551615"); test_dec< long long>( "-1"); } @@ -96,11 +101,11 @@ int main() test_hex< int32_t>( "FFFFFFFF"); test_hex<uint64_t>("FFFFFFFFFFFFFFFF"); test_hex< int64_t>("FFFFFFFFFFFFFFFF"); - if (sizeof(long) == sizeof(int64_t)) { + if (long_is_64) { test_hex<unsigned long>("FFFFFFFFFFFFFFFF"); test_hex< long>("FFFFFFFFFFFFFFFF"); } - if (sizeof(long long) == sizeof(int64_t)) { + if (long_long_is_64) { test_hex<unsigned long long>("FFFFFFFFFFFFFFFF"); test_hex< long long>("FFFFFFFFFFFFFFFF"); } diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp index ec3fe48866c77..bed0d72af8094 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp @@ -56,7 +56,7 @@ int main() assert(seekpos_called == 2); assert(os.fail()); } - { // See https://llvm.org/bugs/show_bug.cgi?id=21361 + { // See https://bugs.llvm.org/show_bug.cgi?id=21361 seekpos_called = 0; testbuf<char> sb; std::ostream os(&sb); diff --git a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp index ebfd24af91d5b..eb76cbf9d28a9 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp @@ -58,7 +58,7 @@ int main() assert(seekoff_called == 2); assert(os.fail()); } - { // See https://llvm.org/bugs/show_bug.cgi?id=21361 + { // See https://bugs.llvm.org/show_bug.cgi?id=21361 seekoff_called = 0; testbuf<char> sb; std::ostream os(&sb); diff --git a/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp index c9fccea2c7d0c..6b550b5dabe41 100644 --- a/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp +++ b/test/std/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp @@ -18,7 +18,7 @@ #include "test_macros.h" -// Test that mismatches between strings and wides streams are diagnosed +// Test that mismatches between strings and wide streams are diagnosed #if TEST_STD_VER > 11 diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp index 1e2ee50632afc..59f0bd4787602 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp @@ -13,6 +13,9 @@ // long& iword(int idx); +// This test compiles but never completes when compiled against the MSVC STL +// UNSUPPORTED: msvc + #include <ios> #include <string> #include <cassert> diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp index 5246ad8f644c4..45115823b4c25 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp @@ -13,6 +13,9 @@ // void*& pword(int idx); +// This test compiles but never completes when compiled against the MSVC STL +// UNSUPPORTED: msvc + #include <ios> #include <string> #include <cassert> diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp index a3c11f7881a9b..d5df1b7c094e5 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // back_insert_iterator @@ -17,8 +19,6 @@ #include <iterator> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - #include <vector> #include <memory> #include <cassert> @@ -32,11 +32,7 @@ test(C c) assert(c.back() == typename C::value_type()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test(std::vector<std::unique_ptr<int> >()); -#endif } diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp index bd2bd44837ab9..af880f871ff5f 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // front_insert_iterator @@ -15,9 +17,6 @@ // operator=(Cont::value_type&& value); #include <iterator> - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - #include <list> #include <memory> #include <cassert> @@ -31,11 +30,7 @@ test(C c) assert(c.front() == typename C::value_type()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES test(std::list<std::unique_ptr<int> >()); -#endif } diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp index f771688f1adc2..ad1fa29ac7cf1 100644 --- a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp +++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <iterator> // insert_iterator @@ -17,7 +19,6 @@ #include <iterator> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include <utility> #include <vector> #include <memory> @@ -52,11 +53,8 @@ struct do_nothing void operator()(void*) const {} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unique_ptr<int, do_nothing> Ptr; typedef std::vector<Ptr> C; @@ -94,5 +92,4 @@ int main() insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5)); test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp index 7f807b63e3ce4..fc6dc0009a0d5 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp @@ -13,7 +13,7 @@ // istream_iterator(const istream_iterator& x); // C++17 says: If is_trivially_copy_constructible_v<T> is true, then -// this constructor shall beis a trivial copy constructor. +// this constructor is a trivial copy constructor. #include <iterator> #include <sstream> diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp index 32dc62817bc41..22f2967f3281a 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// // Usage of is_trivially_constructible is broken with these compilers. -// See https://llvm.org/bugs/show_bug.cgi?id=31016 -// XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0 +// See https://bugs.llvm.org/show_bug.cgi?id=31016 +// XFAIL: clang-3.7, apple-clang-7 && c++1z // <iterator> @@ -17,7 +17,7 @@ // constexpr istream_iterator(); // C++17 says: If is_trivially_default_constructible_v<T> is true, then this -// constructor shall beis a constexpr constructor. +// constructor is a constexpr constructor. #include <iterator> #include <cassert> diff --git a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp index b1bf75b11958a..a680aa3f499be 100644 --- a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp +++ b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp @@ -29,11 +29,11 @@ // If T is a literal type, then this destructor shall be a trivial destructor. // C++17 says: // If is_trivially_default_constructible_v<T> is true, then -// this constructor (the default ctor) shall beis a constexpr constructor. +// this constructor (the default ctor) is a constexpr constructor. // If is_trivially_copy_constructible_v<T> is true, then -// this constructor (the copy ctor) shall beis a trivial copy constructor. +// this constructor (the copy ctor) is a trivial copy constructor. // If is_trivially_destructible_v<T> is true, then this -// destructor shall beis a trivial destructor. +// destructor is a trivial destructor. // Testing the C++17 ctors for this are in the ctor tests. #include <iterator> diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp index 28da3093f3983..ec5d0a445baa9 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -44,7 +44,7 @@ struct alignas(OverAligned) A }; void test_max_alloc() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); auto do_test = []() { void* vp = operator new [](std::numeric_limits<std::size_t>::max(), std::align_val_t(OverAligned), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp index dd4ff46bceb97..5aecc2da0847d 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -38,7 +38,7 @@ struct A int main() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* volatile vp = operator new[] (std::numeric_limits<std::size_t>::max()); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp index 2f51b19904361..c1606b27da79f 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -37,7 +37,7 @@ struct A int main() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); #ifndef TEST_HAS_NO_EXCEPTIONS try #endif diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp index ff55ec74e3cd5..3925f2f5c3136 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp @@ -46,9 +46,11 @@ void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT // selected. struct A { ~A() {} }; +A *volatile x; + int main() { - A* x = new A[3]; + x = new A[3]; assert(0 == delete_called); assert(0 == delete_nothrow_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp index 26f7bc392c79c..df002c60a6bbe 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -38,7 +38,7 @@ struct A int main() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* vp = operator new (std::numeric_limits<std::size_t>::max()); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp index fefae51dac936..5ebbc8a1a2d90 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -45,7 +45,7 @@ struct alignas(OverAligned) A void test_throw_max_size() { #ifndef TEST_HAS_NO_EXCEPTIONS - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); try { void* vp = operator new (std::numeric_limits<std::size_t>::max(), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp index ca8503e8854d5..6e2eca3147710 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp @@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std::max_align_t) * 2; int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -44,7 +44,7 @@ struct alignas(OverAligned) A }; void test_max_alloc() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); auto do_test = []() { void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::align_val_t(OverAligned), diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp index 757e8ae18a473..d85db6c499e96 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp @@ -21,7 +21,7 @@ int new_handler_called = 0; -void new_handler() +void my_new_handler() { ++new_handler_called; std::set_new_handler(0); @@ -37,7 +37,7 @@ struct A int main() { - std::set_new_handler(new_handler); + std::set_new_handler(my_new_handler); #ifndef TEST_HAS_NO_EXCEPTIONS try #endif diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp index ad15b49483d08..ea6c9367b9034 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp @@ -43,9 +43,11 @@ struct A ~A() {A_constructed = false;} }; +A *volatile ap; + int main() { - A* ap = new A; + ap = new A; assert(ap); assert(A_constructed); assert(new_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp index 7369c362fce28..57fb1eb88b6ee 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp @@ -44,9 +44,11 @@ void operator delete(void* p, std::size_t) TEST_NOEXCEPT std::free(p); } +int *volatile x; + int main() { - int *x = new int(42); + x = new int(42); assert(0 == unsized_delete_called); assert(0 == unsized_delete_nothrow_called); assert(0 == sized_delete_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp index 6c91f5ceda868..b85b670fa2d4e 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp @@ -49,9 +49,11 @@ void operator delete(void* p, std::size_t) TEST_NOEXCEPT std::free(p); } +int *volatile x; + int main() { - int *x = new int(42); + x = new int(42); assert(0 == unsized_delete_called); assert(0 == unsized_delete_nothrow_called); assert(0 == sized_delete_called); diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp index 1b6de2367e103..61fca5f125bf7 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp @@ -17,7 +17,7 @@ // NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation. // REQUIRES: fsized-deallocation -// RUN: %build -fsized-deallocation +// RUN: %build -fsized-deallocation -O3 // RUN: %run #if !defined(__cpp_sized_deallocation) diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp index 57d193a411cc1..68cd85038b28a 100644 --- a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -46,12 +46,19 @@ public: C * operator&() const { assert(false); } // should not be called }; +class D : private std::nested_exception {}; + + +class E1 : public std::nested_exception {}; +class E2 : public std::nested_exception {}; +class E : public E1, public E2 {}; + int main() { { try { - A a(3); + A a(3); // not a polymorphic type --> no effect std::rethrow_if_nested(a); assert(true); } @@ -63,6 +70,30 @@ int main() { try { + D s; // inaccessible base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } + { + try + { + E s; // ambiguous base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } + { + try + { throw B(5); } catch (const B& b) diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp index a86d8bcbe201f..26be4db38fba6 100644 --- a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -107,6 +107,16 @@ int main() assert(i == 7); } } + { + try + { + std::throw_with_nested("String literal"); + assert(false); + } + catch (const char * s) + { + } + } #if TEST_STD_VER > 11 { try diff --git a/test/std/language.support/support.types/byte.pass.cpp b/test/std/language.support/support.types/byte.pass.cpp new file mode 100644 index 0000000000000..aed44f91218f2 --- /dev/null +++ b/test/std/language.support/support.types/byte.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> +#include <test_macros.h> + +// XFAIL: c++98, c++03, c++11, c++14 + +// std::byte is not an integer type, nor a character type. +// It is a distinct type for accessing the bits that ultimately make up object storage. + +static_assert( std::is_pod<std::byte>::value, "" ); +static_assert(!std::is_arithmetic<std::byte>::value, "" ); +static_assert(!std::is_integral<std::byte>::value, "" ); + +static_assert(!std::is_same<std::byte, char>::value, "" ); +static_assert(!std::is_same<std::byte, signed char>::value, "" ); +static_assert(!std::is_same<std::byte, unsigned char>::value, "" ); + +// The standard doesn't outright say this, but it's pretty clear that it has to be true. +static_assert(sizeof(std::byte) == 1, "" ); + +int main () {} diff --git a/test/std/language.support/support.types/byteops/and.assign.pass.cpp b/test/std/language.support/support.types/byteops/and.assign.pass.cpp new file mode 100644 index 0000000000000..dec241eb0c41a --- /dev/null +++ b/test/std/language.support/support.types/byteops/and.assign.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator &=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret &= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b &= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b8)) == 0, ""); + static_assert(std::to_integer<int>(test(b1, b9)) == 1, ""); + static_assert(std::to_integer<int>(test(b8, b9)) == 8, ""); + + static_assert(std::to_integer<int>(test(b8, b1)) == 0, ""); + static_assert(std::to_integer<int>(test(b9, b1)) == 1, ""); + static_assert(std::to_integer<int>(test(b9, b8)) == 8, ""); +} diff --git a/test/std/language.support/support.types/byteops/and.pass.cpp b/test/std/language.support/support.types/byteops/and.pass.cpp new file mode 100644 index 0000000000000..22da6e3e0d4c4 --- /dev/null +++ b/test/std/language.support/support.types/byteops/and.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator&(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b1 & b8), "" ); + + static_assert(std::to_integer<int>(b1 & b8) == 0, ""); + static_assert(std::to_integer<int>(b1 & b9) == 1, ""); + static_assert(std::to_integer<int>(b8 & b9) == 8, ""); + + static_assert(std::to_integer<int>(b8 & b1) == 0, ""); + static_assert(std::to_integer<int>(b9 & b1) == 1, ""); + static_assert(std::to_integer<int>(b9 & b8) == 8, ""); +} diff --git a/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp b/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp new file mode 100644 index 0000000000000..298edb22d2491 --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2.0; + } + + +int main () { + constexpr std::byte b1 = test(std::byte{1}); +} diff --git a/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp new file mode 100644 index 0000000000000..f7e0dee9c6bbe --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b2{2}; + constexpr std::byte b3{3}; + + static_assert(noexcept(b <<= 2), "" ); + + static_assert(std::to_integer<int>(test(b2)) == 8, "" ); + static_assert(std::to_integer<int>(test(b3)) == 12, "" ); + +} diff --git a/test/std/language.support/support.types/byteops/lshift.fail.cpp b/test/std/language.support/support.types/byteops/lshift.fail.cpp new file mode 100644 index 0000000000000..c950329334bec --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2 = b1 << 2.0f; +} diff --git a/test/std/language.support/support.types/byteops/lshift.pass.cpp b/test/std/language.support/support.types/byteops/lshift.pass.cpp new file mode 100644 index 0000000000000..b4a8325199ff7 --- /dev/null +++ b/test/std/language.support/support.types/byteops/lshift.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b3{3}; + + static_assert(noexcept(b3 << 2), "" ); + + static_assert(std::to_integer<int>(b1 << 1) == 2, ""); + static_assert(std::to_integer<int>(b1 << 2) == 4, ""); + static_assert(std::to_integer<int>(b3 << 4) == 48, ""); + static_assert(std::to_integer<int>(b3 << 6) == 192, ""); +} diff --git a/test/std/language.support/support.types/byteops/not.pass.cpp b/test/std/language.support/support.types/byteops/not.pass.cpp new file mode 100644 index 0000000000000..734780f194a08 --- /dev/null +++ b/test/std/language.support/support.types/byteops/not.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator~(byte b) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(~b1), "" ); + + static_assert(std::to_integer<int>(~b1) == 254, ""); + static_assert(std::to_integer<int>(~b2) == 253, ""); + static_assert(std::to_integer<int>(~b8) == 247, ""); +} diff --git a/test/std/language.support/support.types/byteops/or.assign.pass.cpp b/test/std/language.support/support.types/byteops/or.assign.pass.cpp new file mode 100644 index 0000000000000..75d6ab4d0a9dc --- /dev/null +++ b/test/std/language.support/support.types/byteops/or.assign.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator |=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret |= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(b |= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b2)) == 3, ""); + static_assert(std::to_integer<int>(test(b1, b8)) == 9, ""); + static_assert(std::to_integer<int>(test(b2, b8)) == 10, ""); + + static_assert(std::to_integer<int>(test(b2, b1)) == 3, ""); + static_assert(std::to_integer<int>(test(b8, b1)) == 9, ""); + static_assert(std::to_integer<int>(test(b8, b2)) == 10, ""); + +} diff --git a/test/std/language.support/support.types/byteops/or.pass.cpp b/test/std/language.support/support.types/byteops/or.pass.cpp new file mode 100644 index 0000000000000..02c547f1dbb60 --- /dev/null +++ b/test/std/language.support/support.types/byteops/or.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator|(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2{2}; + constexpr std::byte b8{8}; + + static_assert(noexcept(b1 | b2), "" ); + + static_assert(std::to_integer<int>(b1 | b2) == 3, ""); + static_assert(std::to_integer<int>(b1 | b8) == 9, ""); + static_assert(std::to_integer<int>(b2 | b8) == 10, ""); + + static_assert(std::to_integer<int>(b2 | b1) == 3, ""); + static_assert(std::to_integer<int>(b8 | b1) == 9, ""); + static_assert(std::to_integer<int>(b8 | b2) == 10, ""); +} diff --git a/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp b/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp new file mode 100644 index 0000000000000..3a0c218aff825 --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator>>(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b >>= 2.0; + } + + +int main () { + constexpr std::byte b1 = test(std::byte{1}); +} diff --git a/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp new file mode 100644 index 0000000000000..5b970258f5e0a --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b >>= 2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b16{16}; + constexpr std::byte b192{192}; + + static_assert(noexcept(b >>= 2), "" ); + + static_assert(std::to_integer<int>(test(b16)) == 4, "" ); + static_assert(std::to_integer<int>(test(b192)) == 48, "" ); +} diff --git a/test/std/language.support/support.types/byteops/rshift.fail.cpp b/test/std/language.support/support.types/byteops/rshift.fail.cpp new file mode 100644 index 0000000000000..14e2fcfa13017 --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator >>(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b2 = b1 >> 2.0f; +} diff --git a/test/std/language.support/support.types/byteops/rshift.pass.cpp b/test/std/language.support/support.types/byteops/rshift.pass.cpp new file mode 100644 index 0000000000000..5ff986a70adef --- /dev/null +++ b/test/std/language.support/support.types/byteops/rshift.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr byte operator <<(byte b, IntegerType shift) noexcept; +// These functions shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + + +constexpr std::byte test(std::byte b) { + return b <<= 2; + } + + +int main () { + constexpr std::byte b100{100}; + constexpr std::byte b115{115}; + + static_assert(noexcept(b100 << 2), "" ); + + static_assert(std::to_integer<int>(b100 >> 1) == 50, ""); + static_assert(std::to_integer<int>(b100 >> 2) == 25, ""); + static_assert(std::to_integer<int>(b115 >> 3) == 14, ""); + static_assert(std::to_integer<int>(b115 >> 6) == 1, ""); + +} diff --git a/test/std/language.support/support.types/byteops/to_integer.fail.cpp b/test/std/language.support/support.types/byteops/to_integer.fail.cpp new file mode 100644 index 0000000000000..8832e506a1185 --- /dev/null +++ b/test/std/language.support/support.types/byteops/to_integer.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr IntegerType to_integer(byte b) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + auto f = std::to_integer<float>(b1); +} diff --git a/test/std/language.support/support.types/byteops/to_integer.pass.cpp b/test/std/language.support/support.types/byteops/to_integer.pass.cpp new file mode 100644 index 0000000000000..4aca0be82deb3 --- /dev/null +++ b/test/std/language.support/support.types/byteops/to_integer.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// template <class IntegerType> +// constexpr IntegerType to_integer(byte b) noexcept; +// This function shall not participate in overload resolution unless +// is_integral_v<IntegerType> is true. + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b3{3}; + + static_assert(noexcept(std::to_integer<int>(b1)), "" ); + static_assert(std::is_same<int, decltype(std::to_integer<int>(b1))>::value, "" ); + static_assert(std::is_same<long, decltype(std::to_integer<long>(b1))>::value, "" ); + static_assert(std::is_same<unsigned short, decltype(std::to_integer<unsigned short>(b1))>::value, "" ); + + static_assert(std::to_integer<int>(b1) == 1, ""); + static_assert(std::to_integer<int>(b3) == 3, ""); +} diff --git a/test/std/language.support/support.types/byteops/xor.assign.pass.cpp b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp new file mode 100644 index 0000000000000..c9b40177a17ca --- /dev/null +++ b/test/std/language.support/support.types/byteops/xor.assign.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte& operator ^=(byte l, byte r) noexcept; + + +constexpr std::byte test(std::byte b1, std::byte b2) { + std::byte bret = b1; + return bret ^= b2; + } + + +int main () { + std::byte b; // not constexpr, just used in noexcept check + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b ^= b), "" ); + + static_assert(std::to_integer<int>(test(b1, b8)) == 9, ""); + static_assert(std::to_integer<int>(test(b1, b9)) == 8, ""); + static_assert(std::to_integer<int>(test(b8, b9)) == 1, ""); + + static_assert(std::to_integer<int>(test(b8, b1)) == 9, ""); + static_assert(std::to_integer<int>(test(b9, b1)) == 8, ""); + static_assert(std::to_integer<int>(test(b9, b8)) == 1, ""); +} diff --git a/test/std/language.support/support.types/byteops/xor.pass.cpp b/test/std/language.support/support.types/byteops/xor.pass.cpp new file mode 100644 index 0000000000000..3d0402b30a550 --- /dev/null +++ b/test/std/language.support/support.types/byteops/xor.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <test_macros.h> + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't like "std::byte b1{1}" +// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0 + +// constexpr byte operator^(byte l, byte r) noexcept; + +int main () { + constexpr std::byte b1{1}; + constexpr std::byte b8{8}; + constexpr std::byte b9{9}; + + static_assert(noexcept(b1 ^ b8), "" ); + + static_assert(std::to_integer<int>(b1 ^ b8) == 9, ""); + static_assert(std::to_integer<int>(b1 ^ b9) == 8, ""); + static_assert(std::to_integer<int>(b8 ^ b9) == 1, ""); + + static_assert(std::to_integer<int>(b8 ^ b1) == 9, ""); + static_assert(std::to_integer<int>(b9 ^ b1) == 8, ""); + static_assert(std::to_integer<int>(b9 ^ b8) == 1, ""); +} diff --git a/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp index 044ba2b976cb7..2e2e973619945 100644 --- a/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp index 4488e9c3f73b4..94e45302f10be 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp @@ -15,8 +15,8 @@ // charT tolower(charT) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <cassert> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp index 0c224e342fa9a..d97dc5747e54f 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp @@ -15,8 +15,8 @@ // const charT* tolower(charT* low, const charT* high) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <string> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp index 0985de5007d69..d2ad328268f11 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp @@ -15,8 +15,8 @@ // charT toupper(charT) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp index ba047754916d0..9ed3d138112af 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp @@ -15,8 +15,8 @@ // const charT* toupper(charT* low, const charT* high) const; -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 #include <locale> #include <string> diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp index df350d3537af3..1664c5537fa13 100644 --- a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp +++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp @@ -14,7 +14,7 @@ // string_type negative_sign() const; // The C++ and C standards are silent. -// On this one, commen sense is the guideline. +// On this one, common sense is the guideline. // If customers complain, I'll endeavor to minimize customer complaints #include <locale> diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp index 32e7249ab868d..72e351f580b4e 100644 --- a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp +++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp index 8edcfc4158218..4d8c2af383837 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp @@ -38,6 +38,12 @@ int main() char str[50]; output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v); std::string ex(str, iter.base()); - assert(ex == "0x0" || ex == "(nil)"); + char expected_str[32] = {}; + // num_put::put uses %p for pointer types, but the exact format of %p is + // implementation defined behavior for the C library. Compare output to + // snprintf for portability. + int rc = snprintf(expected_str, sizeof(expected_str), "%p", v); + assert(rc > 0); + assert(ex == expected_str); } } diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp index 6d7f506bb2d45..272199b0e0d93 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp index 9a06157ada592..af15b174bcd27 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp @@ -13,7 +13,7 @@ // REQUIRES: locale.zh_CN.UTF-8 // GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009" -// GLIBC also failes on the zh_CN test. +// GLIBC also fails on the zh_CN test. // XFAIL: linux // <locale> diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp index 170f33ad9813b..1cd9f462e38e7 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp @@ -13,7 +13,7 @@ // REQUIRES: locale.zh_CN.UTF-8 // GLIBC Expects "10/06/2009" for fr_FR as opposed to "10.06.2009" -// GLIBC also failes on the zh_CN test. +// GLIBC also fails on the zh_CN test. // XFAIL: linux // <locale> diff --git a/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp index 4d710c1a97991..56d6262d06925 100644 --- a/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp +++ b/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp @@ -28,11 +28,11 @@ int main() { { - typedef std::codecvt_utf16<wchar_t> C; + typedef std::codecvt_utf16<char32_t> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -67,11 +67,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x1000> C; + typedef std::codecvt_utf16<char32_t, 0x1000> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -106,11 +106,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp); @@ -145,11 +145,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -184,11 +184,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C; + typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -223,13 +223,13 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode( - std::consume_header | - std::little_endian)> C; + typedef std::codecvt_utf16<char32_t, 0x10ffff, + std::codecvt_mode(std::consume_header | std::little_endian)> C; + C c; - wchar_t w = 0; + char32_t w = 0; char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp); diff --git a/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp index 382ea122641a2..308bb9da2fc19 100644 --- a/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp +++ b/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp @@ -28,11 +28,11 @@ int main() { { - typedef std::codecvt_utf8<wchar_t> C; + typedef std::codecvt_utf8<char32_t> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -67,11 +67,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf8<wchar_t, 0x1000> C; + typedef std::codecvt_utf8<char32_t, 0x1000> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp); @@ -106,11 +106,11 @@ int main() assert(w == 0x56); } { - typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C; + typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C; C c; - wchar_t w = 0; + char32_t w = 0; char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)}; - wchar_t* wp = nullptr; + char32_t* wp = nullptr; std::mbstate_t m; const char* np = nullptr; std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp); diff --git a/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp index 0087f1943b6e0..11346fb402d29 100644 --- a/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp +++ b/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <locale> diff --git a/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp index 8cc71f7bff275..9e2298cf77183 100644 --- a/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp +++ b/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp @@ -34,7 +34,6 @@ test() void test_edges() { - typedef std::complex<double> C; const unsigned N = sizeof(testcases) / sizeof(testcases[0]); for (unsigned i = 0; i < N; ++i) { diff --git a/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp index 9f09ab5827dea..f27ead3daf002 100644 --- a/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp +++ b/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp @@ -35,7 +35,6 @@ test() void test_edges() { - typedef std::complex<double> C; const unsigned N = sizeof(testcases) / sizeof(testcases[0]); for (unsigned i = 0; i < N; ++i) { diff --git a/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp index d34ff1c64d83b..19b74ba28bcd0 100644 --- a/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp +++ b/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <valarray> // template<class T> class valarray; @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; T a[] = {1, 2, 3, 4, 5}; @@ -60,5 +61,4 @@ int main() assert(v2[i][j] == a[i][j]); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp index a9692618e75f7..b8fb08e0f2231 100644 --- a/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp +++ b/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <valarray> // template<class T> class valarray; @@ -20,7 +22,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; T a[] = {1, 2, 3, 4, 5}; @@ -58,5 +59,4 @@ int main() assert(v2[i][j] == a[i][j]); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp index 46741e1e41b7b..f999c5045a5c1 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp @@ -22,6 +22,7 @@ #include <numeric> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -38,7 +39,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -107,7 +108,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y); diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp index fb0bbdc2836da..8a30a82212de1 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp @@ -23,6 +23,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -40,7 +41,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -110,7 +111,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y, std::minus<X>()); diff --git a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index af065b84d1bb1..961b515ef8d88 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 + // <numeric> // template<class _M, class _N> @@ -129,4 +130,11 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res = std::gcd((int64_t)1234, (int32_t)-2147483648); + static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res == 2); + } } diff --git a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index cd03d99ebf131..90d48398f54a7 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -128,4 +128,12 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648); + (void) std::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN + static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res1 == 1324997410816LL); + } } diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp index d70d8f072c395..ca669dc4194a9 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp @@ -31,7 +31,6 @@ int main() { { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = 10; @@ -47,7 +46,6 @@ int main() } { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = -1.5; @@ -63,7 +61,6 @@ int main() } { typedef std::cauchy_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; const double a = .5; diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp index 3b54790aee0ae..3261880c6d04d 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(0.5); @@ -74,7 +73,6 @@ int main() } { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(1); @@ -114,7 +112,6 @@ int main() } { typedef std::chi_squared_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp index 4da7f2e70e9b3..8025880d8754b 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp @@ -51,7 +51,6 @@ int main() // Purposefully only testing even integral values of m and n (for now) { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2, 4); @@ -69,7 +68,6 @@ int main() } { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(4, 2); @@ -87,7 +85,6 @@ int main() } { typedef std::fisher_f_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(18, 20); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp index e1084d3ef03d2..2bf9204d3a091 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::normal_distribution<> D; - typedef D::param_type P; typedef std::minstd_rand G; G g; D d(5, 4); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp index 223d6f4d2216d..71aaa081b351f 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(.75); @@ -74,7 +73,6 @@ int main() } { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(1); @@ -114,7 +112,6 @@ int main() } { typedef std::exponential_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(10); diff --git a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp index 10337907b964e..ee0b68fb8f9c5 100644 --- a/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp +++ b/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp @@ -34,7 +34,6 @@ int main() { { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(0.5, 2); @@ -78,7 +77,6 @@ int main() } { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(1, .5); @@ -122,7 +120,6 @@ int main() } { typedef std::weibull_distribution<> D; - typedef D::param_type P; typedef std::mt19937 G; G g; D d(2, 3); diff --git a/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/test/std/re/re.alg/re.alg.match/awk.pass.cpp index f866929795db8..9bd213f967463 100644 --- a/test/std/re/re.alg/re.alg.match/awk.pass.cpp +++ b/test/std/re/re.alg/re.alg.match/awk.pass.cpp @@ -26,7 +26,8 @@ int main() { -/* { +#if 0 + { std::cmatch m; const char s[] = "a"; assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk))); @@ -263,7 +264,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -278,7 +279,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -293,7 +294,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -326,7 +327,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -341,7 +342,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -356,7 +357,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -378,7 +379,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -394,7 +395,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -410,7 +411,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); assert(m.length(1) == 4); @@ -434,7 +435,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -519,7 +520,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -542,7 +543,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -572,7 +573,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -588,7 +589,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -604,7 +605,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -616,24 +617,23 @@ int main() assert(m.size() == 0); } std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); -*/ { - /* + { std::cmatch m; const char s[] = "m"; - assert(std::regex_match(s, m, std::regex("[a[=M=]z]", - std::regex_constants::awk); - assert(m.size() == 1); + assert(std::regex_match(s, m, + std::regex("[a[=M=]z]", std::regex_constants::awk))); + assert(m.size() == 1); assert(!m.prefix().matched); assert(m.prefix().first == s); assert(m.prefix().second == m[0].first); assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); -*/ } -/* { + } + { std::cmatch m; const char s[] = "Ch"; assert(std::regex_match(s, m, std::regex("[a[.ch.]z]", @@ -645,7 +645,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -688,7 +688,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == 4); + assert((size_t)m.length(0) == 4); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -704,7 +704,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s + std::char_traits<char>::length(s)); - assert(m.length(0) == std::char_traits<char>::length(s)); + assert((size_t)m.length(0) == std::char_traits<char>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -720,7 +720,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s+1); - assert(m.length(0) == 1); + assert((size_t)m.length(0) == 1); assert(m.position(0) == 0); assert(m.str(0) == L"a"); } @@ -735,7 +735,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s+2); - assert(m.length(0) == 2); + assert((size_t)m.length(0) == 2); assert(m.position(0) == 0); assert(m.str(0) == L"ab"); } @@ -945,7 +945,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -960,7 +960,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -975,7 +975,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1008,7 +1008,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1023,7 +1023,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1038,7 +1038,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1060,7 +1060,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1076,7 +1076,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1092,7 +1092,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); assert(m.length(1) == 4); @@ -1116,7 +1116,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1201,7 +1201,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1224,7 +1224,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1254,7 +1254,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1270,7 +1270,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1286,7 +1286,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1310,7 +1310,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1326,7 +1326,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -1385,8 +1385,9 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s)); - assert(m.length(0) == std::char_traits<wchar_t>::length(s)); + assert((size_t)m.length(0) == std::char_traits<wchar_t>::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } -*/} +#endif +} diff --git a/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp index 59b2832c4580a..d9c5172303fcb 100644 --- a/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp +++ b/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp @@ -16,7 +16,7 @@ // const basic_regex<charT, traits>& e, // regex_constants::match_flag_type flags = regex_constants::match_default); -// http://llvm.org/bugs/show_bug.cgi?id=16135 +// https://bugs.llvm.org/show_bug.cgi?id=16135 #include <string> #include <regex> diff --git a/test/std/re/re.alg/re.alg.search/backup.pass.cpp b/test/std/re/re.alg/re.alg.search/backup.pass.cpp index f33b844bed9c5..8de0b650ff050 100644 --- a/test/std/re/re.alg/re.alg.search/backup.pass.cpp +++ b/test/std/re/re.alg/re.alg.search/backup.pass.cpp @@ -25,7 +25,7 @@ int main() { // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...) - // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273. + // Test for https://bugs.llvm.org/show_bug.cgi?id=16240 fixed in r185273. { std::string s("aaaa a"); std::regex re("\\ba"); diff --git a/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp index 93424e188432f..2d753ed14701e 100644 --- a/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp +++ b/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp @@ -16,7 +16,7 @@ // const basic_regex<charT, traits>& e, // regex_constants::match_flag_type flags = regex_constants::match_default); -// http://llvm.org/bugs/show_bug.cgi?id=11118 +// https://bugs.llvm.org/show_bug.cgi?id=11118 #include <regex> #include <cassert> diff --git a/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp index aca4d674d9f99..e66d3e976db22 100644 --- a/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp +++ b/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp @@ -36,7 +36,7 @@ int main() assert(error_badbackref_thrown("ab(c)\\2def")); // only one reference // this should NOT throw, because we only should look at the '1' -// See https://llvm.org/bugs/show_bug.cgi?id=31387 +// See https://bugs.llvm.org/show_bug.cgi?id=31387 { const char *pat1 = "a(b)c\\1234"; std::regex re(pat1, pat1 + 7); // extra chars after the end. diff --git a/test/std/re/re.traits/lookup_classname.pass.cpp b/test/std/re/re.traits/lookup_classname.pass.cpp index 4f7cf61ebf99c..2215b9043d5b6 100644 --- a/test/std/re/re.traits/lookup_classname.pass.cpp +++ b/test/std/re/re.traits/lookup_classname.pass.cpp @@ -35,7 +35,7 @@ test(const char_type* A, int main() { // if __regex_word is not distinct from all the classes, bad things happen -// See https://llvm.org/bugs/show_bug.cgi?id=26476 for an example. +// See https://bugs.llvm.org/show_bug.cgi?id=26476 for an example. assert((std::ctype_base::space & std::regex_traits<char>::__regex_word) == 0); assert((std::ctype_base::print & std::regex_traits<char>::__regex_word) == 0); assert((std::ctype_base::cntrl & std::regex_traits<char>::__regex_word) == 0); diff --git a/test/std/re/re.traits/translate_nocase.pass.cpp b/test/std/re/re.traits/translate_nocase.pass.cpp index bf79629d33b4d..ab73db79d97ff 100644 --- a/test/std/re/re.traits/translate_nocase.pass.cpp +++ b/test/std/re/re.traits/translate_nocase.pass.cpp @@ -16,8 +16,8 @@ // REQUIRES: locale.en_US.UTF-8 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // TODO: investigation needed // XFAIL: linux-gnu diff --git a/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp b/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp new file mode 100644 index 0000000000000..01f01218999df --- /dev/null +++ b/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <string> + +// Test that <string> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <string> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::string>(); + test_hash_enabled_for_type<std::wstring>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test_hash_enabled_for_type<std::u16string>(); + test_hash_enabled_for_type<std::u32string>(); +#endif + } +} diff --git a/test/std/strings/basic.string.hash/strings.pass.cpp b/test/std/strings/basic.string.hash/strings.pass.cpp index 5fc32c06a7014..d74e485752fc6 100644 --- a/test/std/strings/basic.string.hash/strings.pass.cpp +++ b/test/std/strings/basic.string.hash/strings.pass.cpp @@ -22,6 +22,8 @@ #include <cassert> #include <type_traits> +#include "test_macros.h" + template <class T> void test() @@ -29,6 +31,8 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); + H h; std::string g1 = "1234567890"; std::string g2 = "1234567891"; diff --git a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp index b3447b94b8038..982bb43289d75 100644 --- a/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp @@ -18,6 +18,65 @@ #include "test_allocator.h" #include "min_allocator.h" +#ifndef TEST_HAS_NO_EXCEPTIONS +template <class T> +struct alloc_imp { + bool active; + + alloc_imp() : active(true) {} + + T* allocate(std::size_t n) + { + if (active) + return static_cast<T*>(std::malloc(n * sizeof(T))); + else + throw std::bad_alloc(); + } + + void deallocate(T* p, std::size_t) { std::free(p); } + void activate () { active = true; } + void deactivate() { active = false; } +}; + +template <class T> +struct poca_alloc { + typedef T value_type; + typedef std::true_type propagate_on_container_copy_assignment; + + alloc_imp<T> *imp; + + poca_alloc(alloc_imp<T> *imp_) : imp (imp_) {} + + template <class U> + poca_alloc(const poca_alloc<U>& other) : imp(other.imp) {} + + T* allocate (std::size_t n) { return imp->allocate(n);} + void deallocate(T* p, std::size_t n) { imp->deallocate(p, n); } +}; + +template <typename T, typename U> +bool operator==(const poca_alloc<T>& lhs, const poca_alloc<U>& rhs) +{ + return lhs.imp == rhs.imp; +} + +template <typename T, typename U> +bool operator!=(const poca_alloc<T>& lhs, const poca_alloc<U>& rhs) +{ + return lhs.imp != rhs.imp; +} + +template <class S> +void test_assign(S &s1, const S& s2) +{ + try { s1 = s2; } + catch ( std::bad_alloc &) { return; } + assert(false); +} +#endif + + + template <class S> void test(S s1, const typename S::allocator_type& a) @@ -46,5 +105,27 @@ int main() test(S("1"), A()); test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A()); } + +#ifndef TEST_HAS_NO_EXCEPTIONS + { + typedef poca_alloc<char> A; + typedef std::basic_string<char, std::char_traits<char>, A> S; + const char * p1 = "This is my first string"; + const char * p2 = "This is my second string"; + + alloc_imp<char> imp1; + alloc_imp<char> imp2; + S s1(p1, A(&imp1)); + S s2(p2, A(&imp2)); + + assert(s1 == p1); + assert(s2 == p2); + + imp2.deactivate(); + test_assign(s1, s2); + assert(s1 == p1); + assert(s2 == p2); + } +#endif #endif } diff --git a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp index 0c6362d96863d..f4ff0645afcf6 100644 --- a/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp +++ b/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp @@ -42,8 +42,10 @@ int main() typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } +#if defined(_LIBCPP_VERSION) { typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; - LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, ""); + static_assert(!std::is_nothrow_destructible<C>::value, ""); } +#endif // _LIBCPP_VERSION } diff --git a/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp b/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp new file mode 100644 index 0000000000000..0fbd663db4bcd --- /dev/null +++ b/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp @@ -0,0 +1,300 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 +// UNSUPPORTED: libcpp-no-deduction-guides + +// <string> + +// Test that the constructors offered by std::basic_string are formulated +// so they're compatible with implicit deduction guides. + +#include <string> +#include <string_view> +#include <cassert> + +#include "test_macros.h" +#include "test_allocator.h" +#include "test_iterators.h" +#include "constexpr_char_traits.hpp" + +template <class T, class Alloc = std::allocator<T>> +using BStr = std::basic_string<T, std::char_traits<T>, Alloc>; + +// Overloads +// using A = Allocator; +// using BS = basic_string +// using BSV = basic_string_view +// --------------- +// (1) basic_string() - NOT TESTED +// (2) basic_string(A const&) - BROKEN +// (3) basic_string(size_type, CharT, const A& = A()) +// (4) basic_string(BS const&, size_type, A const& = A()) +// (5) basic_string(BS const&, size_type, size_type, A const& = A()) - PARTIALLY BROKEN +// (6) basic_string(const CharT*, size_type, A const& = A()) +// (7) basic_string(const CharT*, A const& = A()) +// (8) basic_string(InputIt, InputIt, A const& = A()) - BROKEN +// (9) basic_string(BS const&) +// (10) basic_string(BS const&, A const&) +// (11) basic_string(BS&&) +// (12) basic_string(BS&&, A const&) +// (13) basic_string(initializer_list<CharT>, A const& = A()) +// (14) basic_string(BSV, A const& = A()) +// (15) basic_string(const T&, size_type, size_type, A const& = A()) - BROKEN +int main() +{ + using TestSizeT = test_allocator<char>::size_type; + { // Testing (1) + // Nothing TODO. Cannot deduce without any arguments. + } + { // Testing (2) + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // const test_allocator<char> alloc{}; + // std::basic_string s(alloc); + } + { // Testing (3) w/o allocator + std::basic_string s(6ull, 'a'); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "aaaaaa"); + + std::basic_string w(2ull, L'b'); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"bb"); + } + { // Testing (3) w/ allocator + std::basic_string s(6ull, 'a', test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), BStr<char,test_allocator<char>>); + assert(s == "aaaaaa"); + + std::basic_string w(2ull, L'b', test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), BStr<wchar_t, test_allocator<wchar_t>>); + assert(w == L"bb"); + } + { // Testing (4) w/o allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)3); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"def"); + } + { // Testing (4) w/ allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"def"); + } + { // Testing (5) w/o allocator +#if 0 // FIXME: This doesn't work + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, (size_t)3); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)2, (TestSizeT)3); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"cde"); +#endif + } + { // Testing (5) w/ allocator + const std::string sin("abc"); + std::basic_string s(sin, (size_t)1, (size_t)3, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "bc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, (TestSizeT)2, (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"cde"); + } + { // Testing (6) w/o allocator + std::basic_string s("abc", (size_t)2); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "ab"); + + std::basic_string w(L"abcdef", (size_t)3); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abc"); + } + { // Testing (6) w/ allocator + std::basic_string s("abc", (size_t)2, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "ab"); + + using WStr = std::basic_string<wchar_t, + std::char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string w(L"abcdef", (TestSizeT)3, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abc"); + } + { // Testing (7) w/o allocator + std::basic_string s("abc"); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + std::basic_string w(L"abcdef"); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abcdef"); + } + { // Testing (7) w/ allocator + std::basic_string s("abc", std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + std::char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string w(L"abcdef", test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // (8) w/o allocator + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // FIXME: Propose adding an explicit guide to the standard? + } + { // (8) w/ allocator + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + // FIXME: Propose adding an explicit guide to the standard? +#if 0 + using It = input_iterator<const char*>; + const char* input = "abcdef"; + std::basic_string s(It(input), It(input + 3), std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); +#endif + } + { // Testing (9) + const std::string sin("abc"); + std::basic_string s(sin); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (10) + const std::string sin("abc"); + std::basic_string s(sin, std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + const WStr win(L"abcdef"); + std::basic_string w(win, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (11) + std::string sin("abc"); + std::basic_string s(std::move(sin)); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + WStr win(L"abcdef"); + std::basic_string w(std::move(win)); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (12) + std::string sin("abc"); + std::basic_string s(std::move(sin), std::allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using WStr = std::basic_string<wchar_t, + constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + WStr win(L"abcdef"); + std::basic_string w(std::move(win), test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), WStr); + assert(w == L"abcdef"); + } + { // Testing (13) w/o allocator + std::basic_string s({'a', 'b', 'c'}); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + std::basic_string w({L'a', L'b', L'c'}); + ASSERT_SAME_TYPE(decltype(w), std::wstring); + assert(w == L"abc"); + } + { // Testing (13) w/ allocator + std::basic_string s({'a', 'b', 'c'}, test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), BStr<char, test_allocator<char>>); + assert(s == "abc"); + + std::basic_string w({L'a', L'b', L'c'}, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), BStr<wchar_t, test_allocator<wchar_t>>); + assert(w == L"abc"); + } + { // Testing (14) w/o allocator + std::string_view sv("abc"); + std::basic_string s(sv); + ASSERT_SAME_TYPE(decltype(s), std::string); + assert(s == "abc"); + + using Expect = std::basic_string<wchar_t, constexpr_char_traits<wchar_t>>; + std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>> BSV(L"abcdef"); + std::basic_string w(BSV); + ASSERT_SAME_TYPE(decltype(w), Expect); + assert(w == L"abcdef"); + } + { // Testing (14) w/ allocator + using ExpectS = std::basic_string<char, std::char_traits<char>, test_allocator<char>>; + std::string_view sv("abc"); + std::basic_string s(sv, test_allocator<char>{}); + ASSERT_SAME_TYPE(decltype(s), ExpectS); + assert(s == "abc"); + + using ExpectW = std::basic_string<wchar_t, constexpr_char_traits<wchar_t>, + test_allocator<wchar_t>>; + std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>> BSV(L"abcdef"); + std::basic_string w(BSV, test_allocator<wchar_t>{}); + ASSERT_SAME_TYPE(decltype(w), ExpectW); + assert(w == L"abcdef"); + } + { // Testing (15) + // This overload isn't compatible with implicit deduction guides as + // specified in the standard. + } +} diff --git a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp index 1b10224cd9e78..1f83696891c4d 100644 --- a/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp @@ -29,7 +29,6 @@ test(It first, It last) { typedef typename std::iterator_traits<It>::value_type charT; typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(first, last); LIBCPP_ASSERT(s2.__invariants()); @@ -47,7 +46,6 @@ test(It first, It last, const A& a) { typedef typename std::iterator_traits<It>::value_type charT; typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(first, last, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == static_cast<std::size_t>(std::distance(first, last))); diff --git a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp index f56780095b7fb..d9d451dc71120 100644 --- a/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp @@ -56,7 +56,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(""); test("", A(2)); @@ -73,7 +72,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(""); test("", A()); diff --git a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp index bcab9eb6789e1..3c75a700eaed9 100644 --- a/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp @@ -53,7 +53,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test("", 0); test("", 0, A(2)); @@ -70,7 +69,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test("", 0); test("", 0, A()); diff --git a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp index 60443e9f358dd..2adf0049a0b5c 100644 --- a/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp +++ b/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp @@ -26,7 +26,6 @@ void test(unsigned n, charT c) { typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(n, c); LIBCPP_ASSERT(s2.__invariants()); @@ -42,7 +41,6 @@ void test(unsigned n, charT c, const A& a) { typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(n, c, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == n); @@ -58,7 +56,6 @@ test(Tp n, Tp c) { typedef char charT; typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S; - typedef typename S::traits_type T; typedef typename S::allocator_type A; S s2(n, c); LIBCPP_ASSERT(s2.__invariants()); @@ -75,7 +72,6 @@ test(Tp n, Tp c, const A& a) { typedef char charT; typedef std::basic_string<charT, std::char_traits<charT>, A> S; - typedef typename S::traits_type T; S s2(n, c, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == static_cast<std::size_t>(n)); @@ -89,7 +85,6 @@ int main() { { typedef test_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(0, 'a'); test(0, 'a', A(2)); @@ -109,7 +104,6 @@ int main() #if TEST_STD_VER >= 11 { typedef min_allocator<char> A; - typedef std::basic_string<char, std::char_traits<char>, A> S; test(0, 'a'); test(0, 'a', A()); diff --git a/test/std/strings/basic.string/string.cons/substr.pass.cpp b/test/std/strings/basic.string/string.cons/substr.pass.cpp index 4fd974273de99..13a9a4b96aaba 100644 --- a/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -98,7 +98,6 @@ void test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a) { typedef typename S::traits_type T; - typedef typename S::allocator_type A; if (pos <= str.size()) { diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp index dac8860f9a642..b464291d4c5dc 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -204,4 +204,20 @@ int main() assert(s == "ABCD"); } + { // test with a move iterator that returns char&& + typedef forward_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef const char* It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp index e5ce8e51e1d6f..2c8b6e4a18828 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -188,10 +188,35 @@ int main() { // test assigning a different type typedef std::string S; - const uint8_t p[] = "ABCD"; + const uint8_t p[] = "ABCD"; - S s; - s.insert(s.begin(), p, p + 4); - assert(s == "ABCD"); + S s; + s.insert(s.begin(), p, p + 4); + assert(s == "ABCD"); } + + { // test with a move iterator that returns char&& + typedef input_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef forward_iterator<const char*> It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } + { // test with a move iterator that returns char&& + typedef const char* It; + typedef std::move_iterator<It> MoveIt; + const char p[] = "ABCD"; + std::string s; + s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); + assert(s == "ABCD"); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp index 840b7614f4820..dbf5f5b644463 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp @@ -29,16 +29,22 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, typename S::size_type n2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + + // String and string_view may not always share the same size type, + // but both types should have the same size (ex. int vs long) + static_assert(sizeof(SizeT) == sizeof(typename SV::size_type), ""); + + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2, n2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(n2, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(n2, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS @@ -64,16 +70,17 @@ test_npos(S s, typename S::size_type pos1, typename S::size_type n1, SV sv, typename S::size_type pos2, S expected) { + typedef typename S::size_type SizeT; static_assert((!std::is_same<S, SV>::value), ""); - const typename S::size_type old_size = s.size(); + const SizeT old_size = s.size(); S s0 = s; if (pos1 <= old_size && pos2 <= sv.size()) { s.replace(pos1, n1, sv, pos2); LIBCPP_ASSERT(s.__invariants()); assert(s == expected); - typename S::size_type xlen = std::min(n1, old_size - pos1); - typename S::size_type rlen = std::min(S::npos, sv.size() - pos2); + SizeT xlen = std::min<SizeT>(n1, old_size - pos1); + SizeT rlen = std::min<SizeT>(S::npos, sv.size() - pos2); assert(s.size() == old_size - xlen + rlen); } #ifndef TEST_HAS_NO_EXCEPTIONS diff --git a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp index 757d5eeb2dc39..88c1bee32512a 100644 --- a/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp +++ b/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -59,10 +59,12 @@ int main() typedef std::string C; static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#if defined(_LIBCPP_VERSION) { typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; - LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); + static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), ""); } +#endif // _LIBCPP_VERSION { typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; #if TEST_STD_VER >= 14 diff --git a/test/std/strings/basic.string/traits_mismatch.fail.cpp b/test/std/strings/basic.string/traits_mismatch.fail.cpp new file mode 100644 index 0000000000000..1d54238ae0c08 --- /dev/null +++ b/test/std/strings/basic.string/traits_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> +// The strings's value type must be the same as the traits's char_type + +#include <string> + +int main() +{ + std::basic_string<char, std::char_traits<wchar_t>> s; +} diff --git a/test/std/strings/string.classes/typedefs.pass.cpp b/test/std/strings/string.classes/typedefs.pass.cpp index 11ee6c8a1215d..3aba1c3f15dd7 100644 --- a/test/std/strings/string.classes/typedefs.pass.cpp +++ b/test/std/strings/string.classes/typedefs.pass.cpp @@ -18,13 +18,14 @@ // typedef basic_string<wchar_t> wstring; #include <string> +#include <type_traits> int main() { - typedef std::string test1; - typedef std::wstring test2; + static_assert((std::is_same<std::string, std::basic_string<char> >::value), ""); + static_assert((std::is_same<std::wstring, std::basic_string<wchar_t> >::value), ""); #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - typedef std::u16string test3; - typedef std::u32string test4; + static_assert((std::is_same<std::u16string, std::basic_string<char16_t> >::value), ""); + static_assert((std::is_same<std::u32string, std::basic_string<char32_t> >::value), ""); #endif // _LIBCPP_HAS_NO_UNICODE_CHARS } diff --git a/test/std/strings/string.conversions/stof.pass.cpp b/test/std/strings/string.conversions/stof.pass.cpp index 1e17e1d3abdda..aeef0ddfbc784 100644 --- a/test/std/strings/string.conversions/stof.pass.cpp +++ b/test/std/strings/string.conversions/stof.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stol.pass.cpp b/test/std/strings/string.conversions/stol.pass.cpp index 457cf0a769979..f01bbf8ce29ee 100644 --- a/test/std/strings/string.conversions/stol.pass.cpp +++ b/test/std/strings/string.conversions/stol.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoll.pass.cpp b/test/std/strings/string.conversions/stoll.pass.cpp index ca8412aeb7583..b823ab7426262 100644 --- a/test/std/strings/string.conversions/stoll.pass.cpp +++ b/test/std/strings/string.conversions/stoll.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoul.pass.cpp b/test/std/strings/string.conversions/stoul.pass.cpp index 1acdf116458f1..5e1f696cb6b7e 100644 --- a/test/std/strings/string.conversions/stoul.pass.cpp +++ b/test/std/strings/string.conversions/stoul.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.conversions/stoull.pass.cpp b/test/std/strings/string.conversions/stoull.pass.cpp index e63679eed2f4d..70563d9be51f8 100644 --- a/test/std/strings/string.conversions/stoull.pass.cpp +++ b/test/std/strings/string.conversions/stoull.pass.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <string> diff --git a/test/std/strings/string.view/string.view.access/at.pass.cpp b/test/std/strings/string.view/string.view.access/at.pass.cpp index 0f1636d3f94f1..6df879898f44b 100644 --- a/test/std/strings/string.view/string.view.access/at.pass.cpp +++ b/test/std/strings/string.view/string.view.access/at.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// NOTE: Older versions of clang have a bug where they fail to evalute +// NOTE: Older versions of clang have a bug where they fail to evaluate // string_view::at as a constant expression. // XFAIL: clang-3.4, clang-3.3 diff --git a/test/std/strings/string.view/string.view.cons/assign.pass.cpp b/test/std/strings/string.view/string.view.cons/assign.pass.cpp new file mode 100644 index 0000000000000..b7348ea226cfa --- /dev/null +++ b/test/std/strings/string.view/string.view.cons/assign.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +// <string_view> + +// constexpr basic_string_view& operator=(const basic_string_view &) noexcept = default; + +#include <string_view> +#include <cassert> + +#include "test_macros.h" + +template<typename T> +#if TEST_STD_VER > 11 +constexpr +#endif +bool test (T sv0) + { + T sv1; + sv1 = sv0; +// We can't just say "sv0 == sv1" here because string_view::compare +// isn't constexpr until C++17, and we want to support back to C++14 + return sv0.size() == sv1.size() && sv0.data() == sv1.data(); + } + +int main () { + + assert( test<std::string_view> ( "1234")); +#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS + assert( test<std::u16string_view> (u"1234")); + assert( test<std::u32string_view> (U"1234")); +#endif + assert( test<std::wstring_view> (L"1234")); + +#if TEST_STD_VER > 11 + static_assert( test<std::string_view> ({ "abc", 3}), ""); +#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert( test<std::u16string_view> ({u"abc", 3}), ""); + static_assert( test<std::u32string_view> ({U"abc", 3}), ""); +#endif + static_assert( test<std::wstring_view> ({L"abc", 3}), ""); +#endif +} diff --git a/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp b/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp new file mode 100644 index 0000000000000..7dd99d9c44057 --- /dev/null +++ b/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 +// UNSUPPORTED: libcpp-no-deduction-guides + +// <string_view> + +// Test that the constructors offered by std::basic_string_view are formulated +// so they're compatible with implicit deduction guides. + +#include <string_view> +#include <cassert> + +#include "test_macros.h" +#include "constexpr_char_traits.hpp" + +// Overloads +// --------------- +// (1) basic_string_view() - NOT TESTED +// (2) basic_string_view(const basic_string_view&) +// (3) basic_string_view(const CharT*, size_type) +// (4) basic_string_view(const CharT*) +int main() +{ + { // Testing (1) + // Nothing TODO. Cannot deduce without any arguments. + } + { // Testing (2) + const std::string_view sin("abc"); + std::basic_string_view s(sin); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "abc"); + + using WSV = std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>>; + const WSV win(L"abcdef"); + std::basic_string_view w(win); + ASSERT_SAME_TYPE(decltype(w), WSV); + assert(w == L"abcdef"); + } + { // Testing (3) + std::basic_string_view s("abc", 2); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "ab"); + + std::basic_string_view w(L"abcdef", 4); + ASSERT_SAME_TYPE(decltype(w), std::wstring_view); + assert(w == L"abcd"); + } + { // Testing (4) + std::basic_string_view s("abc"); + ASSERT_SAME_TYPE(decltype(s), std::string_view); + assert(s == "abc"); + + std::basic_string_view w(L"abcdef"); + ASSERT_SAME_TYPE(decltype(w), std::wstring_view); + assert(w == L"abcdef"); + } +} diff --git a/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp new file mode 100644 index 0000000000000..2e9ebcb4c037a --- /dev/null +++ b/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <string_view> + +// Test that <string_view> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <string_view> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::string_view>(); + test_hash_enabled_for_type<std::wstring_view>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + test_hash_enabled_for_type<std::u16string_view>(); + test_hash_enabled_for_type<std::u32string_view>(); +#endif + } +} diff --git a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp index 63099e2c88647..53c3d261d882b 100644 --- a/test/std/strings/string.view/string.view.hash/string_view.pass.cpp +++ b/test/std/strings/string.view/string.view.hash/string_view.pass.cpp @@ -19,29 +19,41 @@ // Not very portable #include <string_view> +#include <string> #include <cassert> #include <type_traits> +#include "test_macros.h" + using std::string_view; -template <class T> +template <class SV> void test() { - typedef std::hash<T> H; - static_assert((std::is_same<typename H::argument_type, T>::value), "" ); + typedef std::hash<SV> H; + static_assert((std::is_same<typename H::argument_type, SV>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); - H h; -// std::string g1 = "1234567890"; -// std::string g2 = "1234567891"; - typedef typename T::value_type char_type; + + typedef typename SV::value_type char_type; + typedef std::basic_string<char_type> String; + typedef std::hash<String> SH; + ASSERT_NOEXCEPT(H()(SV())); + char_type g1 [ 10 ]; char_type g2 [ 10 ]; for ( int i = 0; i < 10; ++i ) g1[i] = g2[9-i] = static_cast<char_type>('0' + i); - T s1(g1, 10); - T s2(g2, 10); + H h; + SH sh; + SV s1(g1, 10); + String ss1(s1); + SV s2(g2, 10); + String ss2(s2); + assert(h(s1) == h(s1)); assert(h(s1) != h(s2)); + assert(sh(ss1) == h(s1)); + assert(sh(ss2) == h(s2)); } int main() diff --git a/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp b/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp index 381f792e5ce06..16a4da8827398 100644 --- a/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp +++ b/test/std/strings/string.view/string.view.iterators/rbegin.pass.cpp @@ -58,4 +58,23 @@ int main() test(u16string_view{u"123"}); test(u32string_view{U"123"}); #endif + +#if TEST_STD_VER > 14 + { + constexpr string_view sv { "123", 3 }; + constexpr u16string_view u16sv {u"123", 3 }; + constexpr u32string_view u32sv {U"123", 3 }; + constexpr wstring_view wsv {L"123", 3 }; + + static_assert ( *sv.rbegin() == sv[2], "" ); + static_assert ( *u16sv.rbegin() == u16sv[2], "" ); + static_assert ( *u32sv.rbegin() == u32sv[2], "" ); + static_assert ( *wsv.rbegin() == wsv[2], "" ); + + static_assert ( *sv.crbegin() == sv[2], "" ); + static_assert ( *u16sv.crbegin() == u16sv[2], "" ); + static_assert ( *u32sv.crbegin() == u32sv[2], "" ); + static_assert ( *wsv.crbegin() == wsv[2], "" ); + } +#endif } diff --git a/test/std/strings/string.view/string.view.iterators/rend.pass.cpp b/test/std/strings/string.view/string.view.iterators/rend.pass.cpp index ca529fb708dc0..08f9e5a7755b2 100644 --- a/test/std/strings/string.view/string.view.iterators/rend.pass.cpp +++ b/test/std/strings/string.view/string.view.iterators/rend.pass.cpp @@ -66,4 +66,23 @@ int main() test(u16string_view{u"123"}); test(u32string_view{U"123"}); #endif + +#if TEST_STD_VER > 14 + { + constexpr string_view sv { "123", 3 }; + constexpr u16string_view u16sv {u"123", 3 }; + constexpr u32string_view u32sv {U"123", 3 }; + constexpr wstring_view wsv {L"123", 3 }; + + static_assert ( *--sv.rend() == sv[0], "" ); + static_assert ( *--u16sv.rend() == u16sv[0], "" ); + static_assert ( *--u32sv.rend() == u32sv[0], "" ); + static_assert ( *--wsv.rend() == wsv[0], "" ); + + static_assert ( *--sv.crend() == sv[0], "" ); + static_assert ( *--u16sv.crend() == u16sv[0], "" ); + static_assert ( *--u32sv.crend() == u32sv[0], "" ); + static_assert ( *--wsv.crend() == wsv[0], "" ); + } +#endif } diff --git a/test/std/strings/string.view/string_view.literals/literal.pass.cpp b/test/std/strings/string.view/string_view.literals/literal.pass.cpp index 9fb128ab0f554..710009cc51ee9 100644 --- a/test/std/strings/string.view/string_view.literals/literal.pass.cpp +++ b/test/std/strings/string.view/string_view.literals/literal.pass.cpp @@ -48,7 +48,7 @@ int main() Lfoo = L"ABC"sv; assert(Lfoo == L"ABC"); assert(Lfoo == std::wstring_view ( L"ABC")); ufoo = u"ABC"sv; assert(ufoo == u"ABC"); assert(ufoo == std::u16string_view( u"ABC")); Ufoo = U"ABC"sv; assert(Ufoo == U"ABC"); assert(Ufoo == std::u32string_view( U"ABC")); - + static_assert( "ABC"sv.size() == 3, ""); static_assert(u8"ABC"sv.size() == 3, ""); static_assert( L"ABC"sv.size() == 3, ""); diff --git a/test/std/strings/string.view/nothing_to_do.pass.cpp b/test/std/strings/string.view/traits_mismatch.fail.cpp index 353dd98f415e5..6cd15e6a67ba3 100644 --- a/test/std/strings/string.view/nothing_to_do.pass.cpp +++ b/test/std/strings/string.view/traits_mismatch.fail.cpp @@ -7,6 +7,12 @@ // //===----------------------------------------------------------------------===// +// <string_view> +// The string_views's value type must be the same as the traits's char_type + #include <string_view> -int main () {} +int main() +{ + std::basic_string_view<char, std::char_traits<wchar_t>> s; +} diff --git a/test/std/thread/futures/futures.future_error/what.pass.cpp b/test/std/thread/futures/futures.future_error/what.pass.cpp index a44f8af7d41b4..cc2d978d2c2b4 100644 --- a/test/std/thread/futures/futures.future_error/what.pass.cpp +++ b/test/std/thread/futures/futures.future_error/what.pass.cpp @@ -12,8 +12,8 @@ // LWG 2056 changed the values of future_errc, so if we're using new headers // with an old library we'll get incorrect messages. // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin13 // <future> diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp index e0c6e15d98d5e..e986885c0c713 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp @@ -6,7 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// + +// UNSUPPORTED: c++98, c++03 // UNSUPPORTED: libcpp-has-no-threads, libcpp-no-exceptions // <future> @@ -19,8 +20,6 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - struct A { A() {} @@ -28,11 +27,8 @@ struct A A(A&&) {throw 9;} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unique_ptr<int> T; T i(new int(3)); @@ -65,5 +61,4 @@ int main() assert(j == 9); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp index 8f3b76865e2a8..05675725bf437 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -19,23 +19,17 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - void func(std::promise<std::unique_ptr<int>> p) { p.set_value_at_thread_exit(std::unique_ptr<int>(new int(5))); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::promise<std::unique_ptr<int>> p; std::future<std::unique_ptr<int>> f = p.get_future(); std::thread(func, std::move(p)).detach(); assert(*f.get() == 5); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp index 39784876b8c31..7cac21d48aefa 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp @@ -69,7 +69,7 @@ int main() p(3, 'a'); assert(f.get() == 105.0); assert(A::n_copies > 0); - assert(A::n_moves > 0); + assert(A::n_moves >= 0); } assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; diff --git a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp index 8d38b81f0cdad..4a790b06cfdfb 100644 --- a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -72,5 +71,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp index e12c920886fac..14e2eb4169614 100644 --- a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -66,5 +65,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp index ef011d8df7529..9b8667e538cc2 100644 --- a/test/std/thread/futures/futures.unique_future/share.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -25,14 +25,16 @@ int main() typedef int T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -40,14 +42,16 @@ int main() typedef int& T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int& T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -55,14 +59,16 @@ int main() typedef void T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef void T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } diff --git a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp index d60e429188607..de225fe78384e 100644 --- a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp +++ b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// REQUIRES: libcpp-has-thread-api-pthread // notify_all_at_thread_exit(...) requires move semantics to transfer the // unique_lock. diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp index a2b7061c25467..71cbc94a70a42 100644 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -24,8 +24,8 @@ // ----------------------------------------------------------------------------- // Overview -// Check that std::terminate is called if wait(...) fails to meet it's post -// conditions. This can happens when reacquiring the mutex throws +// Check that std::terminate is called if wait(...) fails to meet its post +// conditions. This can happen when reacquiring the mutex throws // an exception. // // The following methods are tested within this file @@ -37,7 +37,7 @@ // 6. void wait_until(Lock& lock, TimePoint, Pred); // // Plan -// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is aquired +// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is acquired // for the *second* time. // // 2 Replace the terminate handler with one that exits with a '0' exit code. diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index 46d04cdac350e..245c480885b83 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -9,10 +9,10 @@ // // UNSUPPORTED: libcpp-has-no-threads -// This test hangs forever when built against libstdc++. In order to allow +// This test hangs forever when built against libstdc++ and MSVC. In order to allow // validation of the test suite against other STLs we have to mark it // unsupported. -// UNSUPPORTED: libstdc++ +// UNSUPPORTED: libstdc++, msvc // <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp index a15405fcd98b1..fffd087ee8776 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit lock_guard(mutex_type& m); +// template<class _Mutex> lock_guard(lock_guard<_Mutex>) +// -> lock_guard<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::lock_guard lg(m); + static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp deleted file mode 100644 index 0ad16e2856fd8..0000000000000 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// <mutex> - -// template <class ...Mutex> class lock_guard; - -// Test that the variadic lock guard implementation compiles in all standard -// dialects, including C++03, even though it is forward declared using -// variadic templates. - -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#include "mutex.pass.cpp" // Use the existing non-variadic test diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp index 81fc0d368f6a8..78165383a1585 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp @@ -8,18 +8,17 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(Mutex&..., adopt_lock_t); +// scoped_lock(Mutex&..., adopt_lock_t); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> +#include "test_macros.h" struct TestMutex { bool locked = false; @@ -36,12 +35,22 @@ struct TestMutex { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg(std::adopt_lock); } { + TestMutex m1; + using LG = std::scoped_lock<TestMutex>; + m1.lock(); + { + LG lg(m1, std::adopt_lock); + assert(m1.locked); + } + assert(!m1.locked); + } + { TestMutex m1, m2; - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex>; m1.lock(); m2.lock(); { LG lg(m1, m2, std::adopt_lock); @@ -51,7 +60,7 @@ int main() } { TestMutex m1, m2, m3; - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; m1.lock(); m2.lock(); m3.lock(); { LG lg(m1, m2, m3, std::adopt_lock); diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp index 1b4c9d4bfd5d6..a054729355269 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard& operator=(lock_guard const&) = delete; +// scoped_lock& operator=(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { @@ -26,18 +25,24 @@ int main() M m0, m1, m2; M om0, om1, om2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg1, lg2; lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg1(m0); + LG lg2(om0); + lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} + } + { + using LG = std::scoped_lock<M, M>; LG lg1(m0, m1); LG lg2(om0, om1); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg1(m0, m1, m2); LG lg2(om0, om1, om2); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp index c7fd0e94b771e..5075a42680952 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp @@ -8,34 +8,38 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(lock_guard const&) = delete; +// scoped_lock(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { using M = std::mutex; M m0, m1, m2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; const LG Orig; LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + const LG Orig(m0); + LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} + } + { + using LG = std::scoped_lock<M, M>; const LG Orig(m0, m1); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; const LG Orig(m0, m1, m2); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp index 1eef7e268fb25..7bb4673265cf1 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(Mutex&...); +// explicit scoped_lock(Mutex&...); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" template <class LG> void test_conversion(LG) {} @@ -29,19 +28,25 @@ int main() M m0, m1, m2; M n0, n1, n2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}} + test_conversion<LG>({n0}); // expected-error{{no matching function for call}} + ((void)lg); + } + { + using LG = std::scoped_lock<M, M>; LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp index 8d83ddf98c6db..ef39bbcc5e888 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp @@ -8,19 +8,16 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(mutex_type& m); +// explicit scoped_lock(mutex_type& m); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> - #include "test_macros.h" struct TestMutex { @@ -68,11 +65,20 @@ struct TestMutexThrows { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg; } { - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex>; + TestMutex m1; + { + LG lg(m1); + assert(m1.locked); + } + assert(!m1.locked); + } + { + using LG = std::scoped_lock<TestMutex, TestMutex>; TestMutex m1, m2; { LG lg(m1, m2); @@ -81,7 +87,7 @@ int main() assert(!m1.locked && !m2.locked); } { - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; TestMutex m1, m2, m3; { LG lg(m1, m2, m3); @@ -92,7 +98,18 @@ int main() #if !defined(TEST_HAS_NO_EXCEPTIONS) { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT>; + using LG = std::scoped_lock<MT>; + MT m1; + m1.throws_on_lock = true; + try { + LG lg(m1); + assert(false); + } catch (int) {} + assert(!m1.locked); + } + { + using MT = TestMutexThrows; + using LG = std::scoped_lock<MT, MT>; MT m1, m2; m1.throws_on_lock = true; try { @@ -103,7 +120,7 @@ int main() } { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT, MT>; + using LG = std::scoped_lock<MT, MT, MT>; MT m1, m2, m3; m2.throws_on_lock = true; try { @@ -113,4 +130,26 @@ int main() assert(!m1.locked && !m2.locked && !m3.locked); } #endif + +#ifdef __cpp_deduction_guides + { + TestMutex m1, m2, m3; + { + std::scoped_lock sl{}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<>>::value), "" ); + } + { + std::scoped_lock sl{m1}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2, m3}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2), decltype(m3)>>::value), "" ); + } + } +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp index 600399d9793e1..6af3c6c952d77 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp @@ -8,22 +8,21 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class Mutex> -// class lock_guard +// template <class Mutex...> +// class scoped_lock // { // public: -// typedef Mutex mutex_type; +// typedef Mutex mutex_type; // only if sizeof...(Mutex) == 1 // ... // }; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <type_traits> +#include "test_macros.h" struct NAT {}; @@ -41,39 +40,39 @@ constexpr bool has_mutex_type() { int main() { { - using T = std::lock_guard<>; + using T = std::scoped_lock<>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M2>; + using T = std::scoped_lock<M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M2>; + using T = std::scoped_lock<M1, M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1, M1>; + using T = std::scoped_lock<M1, M1>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M1>; + using T = std::scoped_lock<M1, M1, M1>; static_assert(!has_mutex_type<T>(), ""); } } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp index f9a537085c30e..ac338064d1fd9 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -18,6 +18,9 @@ // explicit shared_lock(mutex_type& m); +// template<class _Mutex> shared_lock(shared_lock<_Mutex>) +// -> shared_lock<_Mutex>; // C++17 + #include <shared_mutex> #include <thread> #include <vector> @@ -92,4 +95,9 @@ int main() t.join(); q.join(); } + +#ifdef __cpp_deduction_guides + std::shared_lock sl(m); + static_assert((std::is_same<decltype(sl), std::shared_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp index e5db685e46e75..6f17383298fd1 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m0; @@ -46,5 +45,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp index 427deabc5a59d..04aa796734312 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m; @@ -42,5 +41,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp index 1f7217a8300e1..ca8bc69822531 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit unique_lock(mutex_type& m); +// template<class _Mutex> unique_lock(unique_lock<_Mutex>) +// -> unique_lock<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::unique_lock ul(m); + static_assert((std::is_same<decltype(ul), std::unique_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp index 2db9430a698d9..d3478818c0562 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -44,7 +44,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { assert(G::n_alive == 0); assert(!G::op_run); @@ -61,5 +60,4 @@ int main() assert(G::n_alive == 0); assert(G::op_run); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index 437b420379135..d419b8cc855c9 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -106,7 +106,7 @@ public: // A Each allocation performed during thread construction should be performed // in the parent thread so that std::terminate is not called if // std::bad_alloc is thrown by new. -// B std::threads constructor should properly handle exceptions and not leak +// B std::thread's constructor should properly handle exceptions and not leak // memory. // Plan: // 1 Create a thread and count the number of allocations, 'N', it performs. diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp index e88304ec8da9d..f349e4c56fcb9 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -53,7 +53,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { G g; assert(G::n_alive == 1); @@ -68,5 +67,4 @@ int main() assert(G::op_run); } assert(G::n_alive == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp new file mode 100644 index 0000000000000..9799467c4529f --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <thread> + +// Test that <thread> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <thread> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::thread::id>(); + } +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp index 106c69e2e4a1f..4f1491decd318 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp @@ -9,7 +9,7 @@ // // UNSUPPORTED: libcpp-has-no-threads -// <functional> +// <thread> // template <class T> // struct hash @@ -23,6 +23,8 @@ #include <thread> #include <cassert> +#include "test_macros.h" + int main() { std::thread::id id1; @@ -30,6 +32,7 @@ int main() typedef std::hash<std::thread::id> H; static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(id2)); H h; assert(h(id1) != h(id2)); } diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp index ef3b9302c7a2b..dfb187b6cc2df 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp @@ -87,7 +87,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp index 6f31d264280a6..9689fb0147862 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp @@ -88,7 +88,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp index a761b32880606..92df0f6f2264f 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp @@ -87,7 +87,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp index de33eeb2fbda9..2b7fe3f641ae5 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp @@ -83,7 +83,6 @@ void test_no_inner_alloc() void test_with_inner_alloc() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp index 867cc74082e7d..8568c7380b6d0 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp @@ -31,7 +31,6 @@ // OUTERMOST_ALLOC_TRAITS(*this)::construct( // OUTERMOST (*this), p, std::forward<Args>(args)...). void test_bullet_one() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -41,7 +40,6 @@ void test_bullet_one() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(!std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); @@ -66,7 +64,6 @@ void test_bullet_one() { // true, calls OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST (*this), p, // allocator_arg, inner_allocator(), std::forward<Args>(args)...). void test_bullet_two() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -76,7 +73,6 @@ void test_bullet_two() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); @@ -101,7 +97,6 @@ void test_bullet_two() { // OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST (*this), p, // std::forward<Args>(args)..., inner_allocator()). void test_bullet_three() { - using VoidAlloc1 = CountingAllocator<void, 1>; using VoidAlloc2 = CountingAllocator<void, 2>; AllocController POuter; @@ -111,7 +106,6 @@ void test_bullet_three() { using Outer = CountingAllocator<T, 1>; using Inner = CountingAllocator<T, 2>; using SA = std::scoped_allocator_adaptor<Outer, Inner>; - using SAInner = std::scoped_allocator_adaptor<Inner>; static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); T* ptr = (T*)::operator new(sizeof(T)); diff --git a/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp b/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp index 65d94fd1e0a48..75dfb0a2e7044 100644 --- a/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp +++ b/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp @@ -11,9 +11,9 @@ // <any> -// template <class T, class ...Args> emplace(Args&&...); +// template <class T, class ...Args> T& emplace(Args&&...); // template <class T, class U, class ...Args> -// void emplace(initializer_list<U>, Args&&...); +// T& emplace(initializer_list<U>, Args&&...); #include <any> #include <cassert> @@ -42,7 +42,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(); + auto &v = a.emplace<Type>(); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -56,7 +58,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(101); + auto &v = a.emplace<Type>(101); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -70,7 +74,9 @@ void test_emplace_type() { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(-1, 42, -1); + auto &v = a.emplace<Type>(-1, 42, -1); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); assert(Tracked::count == 0); assert(Type::count == 1); @@ -89,14 +95,20 @@ void test_emplace_type_tracked() { { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(); + auto &v = a.emplace<Type>(); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type>(a); } { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>(-1, 42, -1); + auto &v = a.emplace<Type>(-1, 42, -1); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, int, int, int>(a); } @@ -104,7 +116,10 @@ void test_emplace_type_tracked() { { any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>({-1, 42, -1}); + auto &v = a.emplace<Type>({-1, 42, -1}); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, std::initializer_list<int>>(a); } @@ -112,7 +127,10 @@ void test_emplace_type_tracked() { int x = 42; any a(std::in_place_type<Tracked>); assert(Tracked::count == 1); - a.emplace<Type>({-1, 42, -1}, x); + auto &v = a.emplace<Type>({-1, 42, -1}, x); + static_assert( std::is_same_v<Type&, decltype(v)>, "" ); + assert(&v == std::any_cast<Type>(&a)); + assert(Tracked::count == 0); assertArgsMatch<Type, std::initializer_list<int>, int&>(a); } diff --git a/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp b/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp index 99cc029971a84..bbc135051ef8e 100644 --- a/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp +++ b/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp @@ -25,13 +25,30 @@ using std::any_cast; int main() { any a(1); - any_cast<int &>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int &&>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const&&>(&a); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &&>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &>(&a); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const&&>(&a); // expected-note {{requested here}} + any const& a2 = a; - any_cast<int &>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int &&>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} - any_cast<int const &&>(&a2); // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int &&>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &>(&a2); // expected-note {{requested here}} + + // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast<int const &&>(&a2); // expected-note {{requested here}} } diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp index 5e347c4c57156..943e162172b05 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// https://llvm.org/bugs/show_bug.cgi?id=23141 +// https://bugs.llvm.org/show_bug.cgi?id=23141 #include <functional> #include <type_traits> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp index ad03e8fb6bb24..a4d502bb800e8 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=16385 +// https://bugs.llvm.org/show_bug.cgi?id=16385 #include <functional> #include <cmath> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp index 180433109f26f..a9a38b83cb4eb 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=22003 +// https://bugs.llvm.org/show_bug.cgi?id=22003 #include <functional> diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp index 0d4244b4d8605..5b660da617a8f 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp @@ -16,7 +16,7 @@ // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> // unspecified bind(Fn, Types...); -// http://llvm.org/bugs/show_bug.cgi?id=16343 +// https://bugs.llvm.org/show_bug.cgi?id=16343 #include <cmath> #include <functional> diff --git a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp index 47a3e1cc59698..2b19211be9bf4 100644 --- a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp +++ b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp @@ -414,7 +414,14 @@ void throws_in_constructor_test() throw 42; } ThrowsOnCopy() = default; - bool operator()() const { assert(false); } + bool operator()() const { + assert(false); +#if defined(_LIBCPP_MSVC) + __assume(0); +#else + __builtin_unreachable(); +#endif + } }; { ThrowsOnCopy cp; diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp index 5bdf9e98e897a..812f6fc502d9f 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp @@ -8,11 +8,11 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 -// REQUIRES-ANY: c++11, c++14 +// REQUIRES: c++11 || c++14 // <functional> -// See https://llvm.org/bugs/show_bug.cgi?id=20002 +// See https://bugs.llvm.org/show_bug.cgi?id=20002 #include <functional> #include <type_traits> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp index f89bde8e65440..3affd984af600 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp @@ -14,7 +14,7 @@ // function(Fp); // Ensure that __not_null works for all function types. -// See https://llvm.org/bugs/show_bug.cgi?id=23589 +// See https://bugs.llvm.org/show_bug.cgi?id=23589 //------------------------------------------------------------------------------ // TESTING std::function<...>::__not_null(Callable) @@ -31,7 +31,7 @@ // types can be null. The other categories are not tested here. // 3) '__not_null(Callable)' is well formed when the call signature includes // varargs. -// 4) '__not_null(Callable)' works for Callable types with all aritys less +// 4) '__not_null(Callable)' works for Callable types with all arities less // than or equal to 3 in C++03. // 5) '__not_null(Callable)' works when 'Callable' is a member function // pointer to a cv or ref qualified function type. diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index 392dfc1993bce..adc7856357e70 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index 8d454723320c4..4c1a1ca95ff4a 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 ||c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index 718aa49341d22..8b0e831287a5f 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 354ad955f207a..943e170878f24 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> -// REQUIRES-ANY: c++98, c++03, c++11, c++14 +// REQUIRES: c++98 || c++03 || c++11 || c++14 // class function<R(ArgTypes...)> diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index e328481b274d0..3e5435da1a16b 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 -// REQUIRES-ANY: c++11, c++14 +// REQUIRES: c++11 || c++14 // <functional> diff --git a/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp new file mode 100644 index 0000000000000..775247fc80b68 --- /dev/null +++ b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <functional> + +// Test that <functional> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <functional> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); +} diff --git a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp index af367789a105b..a7ddd9a499977 100644 --- a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp @@ -36,6 +36,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); typedef typename std::underlying_type<T>::type under_type; H h1; @@ -43,7 +44,8 @@ test() for (int i = 0; i <= 5; ++i) { T t(static_cast<T> (i)); - if (sizeof(T) <= sizeof(std::size_t)) + const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings + if (small) assert(h1(t) == h2(static_cast<under_type>(i))); } } diff --git a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp index 643e2d8c5d860..e67aa016c1e74 100644 --- a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp @@ -24,6 +24,8 @@ #include <limits> #include <cmath> +#include "test_macros.h" + template <class T> void test() @@ -31,6 +33,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; std::size_t t0 = h(0.); diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp index 2f3f9bee4bc36..ce87f5918b20b 100644 --- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp @@ -31,12 +31,14 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; for (int i = 0; i <= 5; ++i) { T t(static_cast<T>(i)); - if (sizeof(T) <= sizeof(std::size_t)) + const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings + if (small) { const std::size_t result = h(t); LIBCPP_ASSERT(result == static_cast<size_t>(t)); @@ -63,42 +65,42 @@ int main() test<long long>(); test<unsigned long long>(); -// LWG #2119 +// LWG #2119 test<std::ptrdiff_t>(); test<size_t>(); - test<int8_t>(); - test<int16_t>(); - test<int32_t>(); - test<int64_t>(); + test<int8_t>(); + test<int16_t>(); + test<int32_t>(); + test<int64_t>(); - test<int_fast8_t>(); - test<int_fast16_t>(); - test<int_fast32_t>(); - test<int_fast64_t>(); + test<int_fast8_t>(); + test<int_fast16_t>(); + test<int_fast32_t>(); + test<int_fast64_t>(); - test<int_least8_t>(); - test<int_least16_t>(); - test<int_least32_t>(); - test<int_least64_t>(); + test<int_least8_t>(); + test<int_least16_t>(); + test<int_least32_t>(); + test<int_least64_t>(); test<intmax_t>(); test<intptr_t>(); - test<uint8_t>(); - test<uint16_t>(); - test<uint32_t>(); - test<uint64_t>(); + test<uint8_t>(); + test<uint16_t>(); + test<uint32_t>(); + test<uint64_t>(); - test<uint_fast8_t>(); - test<uint_fast16_t>(); - test<uint_fast32_t>(); - test<uint_fast64_t>(); + test<uint_fast8_t>(); + test<uint_fast16_t>(); + test<uint_fast32_t>(); + test<uint_fast64_t>(); - test<uint_least8_t>(); - test<uint_least16_t>(); - test<uint_least32_t>(); - test<uint_least64_t>(); + test<uint_least8_t>(); + test<uint_least16_t>(); + test<uint_least32_t>(); + test<uint_least64_t>(); test<uintmax_t>(); test<uintptr_t>(); diff --git a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp index a48394495e2d5..36280a38e0a7f 100644 --- a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp @@ -23,6 +23,8 @@ #include <type_traits> #include <limits> +#include "test_macros.h" + template <class T> void test() @@ -30,6 +32,7 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); H h; typedef typename std::remove_pointer<T>::type type; @@ -38,7 +41,20 @@ test() assert(h(&i) != h(&j)); } +// can't hash nullptr_t until c++17 +void test_nullptr() +{ +#if TEST_STD_VER > 14 + typedef std::nullptr_t T; + typedef std::hash<T> H; + static_assert((std::is_same<typename H::argument_type, T>::value), "" ); + static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); +#endif +} + int main() { test<int*>(); + test_nullptr(); } diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp index 533d516707e10..05e55e3d9a4e5 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp @@ -80,7 +80,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_default_construct(It(p), It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); std::uninitialized_default_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp index f22a74f1f832c..e5b9eca439cf8 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp @@ -80,7 +80,7 @@ void test_counted() It e = std::uninitialized_default_construct_n(It(p), 1); assert(e == It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); e = std::uninitialized_default_construct_n(It(p+1), 4); assert(e == It(p+N)); assert(Counted::count == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp index c2d860694a756..8479ce123a786 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp @@ -79,7 +79,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_value_construct(It(p), It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); std::uninitialized_value_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp index 323d00f7c9c41..ad6a51500e36f 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp @@ -81,7 +81,7 @@ void test_counted() It e = std::uninitialized_value_construct_n(It(p), 1); assert(e == It(p+1)); assert(Counted::count == 1); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); e = std::uninitialized_value_construct_n(It(p+1), 4); assert(e == It(p+N)); assert(Counted::count == 5); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp index d7a9542b4c273..6c535250fd1f1 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp @@ -88,7 +88,7 @@ void test_counted() Counted* p = (Counted*)pool; auto ret = std::uninitialized_move(It(values), It(values + 1), FIt(p)); assert(ret == FIt(p +1)); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); assert(Counted::count == 1); assert(p[0].value == 1); assert(values[0] == 0); diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp index f27e5726135f0..4175c6bce6880 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp @@ -89,7 +89,7 @@ void test_counted() auto ret = std::uninitialized_move_n(It(values), 1, FIt(p)); assert(ret.first == It(values +1)); assert(ret.second == FIt(p +1)); - assert(Counted::constructed = 1); + assert(Counted::constructed == 1); assert(Counted::count == 1); assert(p[0].value == 1); assert(values[0] == 0); diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp deleted file mode 100644 index 286e6bc9a7b91..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s1(new A[3]); - A* p = s1.get(); - assert(A::count == 3); - std::unique_ptr<A[]> s2(new A[2]); - assert(A::count == 5); - s2 = std::move(s1); - assert(A::count == 3); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5)); - A* p = s1.get(); - assert(A::count == 4); - std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]); - assert(A::count == 9); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 4); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A[]> d1(5); - std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1); - A* p = s1.get(); - assert(A::count == 6); - CDeleter<A[]> d2(6); - std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2); - assert(A::count == 9); - s2 = std::move(s1); - assert(A::count == 6); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp deleted file mode 100644 index 3712a27963929..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp deleted file mode 100644 index 4e85e5b0fb906..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp deleted file mode 100644 index 9461958a431dd..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't assign from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp deleted file mode 100644 index 1737136f4d72a..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp deleted file mode 100644 index 3c89bb12344eb..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp deleted file mode 100644 index 970beb5a150e9..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -// Can't assign from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp deleted file mode 100644 index 786858dd40169..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp deleted file mode 100644 index 46d4c0985d716..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp deleted file mode 100644 index 65ee2694156f6..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2(new A); - assert(A::count == 2); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp deleted file mode 100644 index da08195ffdd3a..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = (boost::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp deleted file mode 100644 index aeec076cb86ab..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include <memory> -#include <utility> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp deleted file mode 100644 index e2d7956cda643..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp deleted file mode 100644 index 50389978e8abb..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include <memory> -#include <cassert> - -#include "test_macros.h" - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int[], Deleter&> p(nullptr, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#if defined(_LIBCPP_VERSION) - { - // The standard only requires the constructor accept nullptr, but libc++ - // also supports the literal 0. - std::unique_ptr<int[], Deleter&> p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } -#endif - assert(d.state() == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp deleted file mode 100644 index 30ecdded3cf7b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s2(new A[3]); - assert(A::count == 3); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp deleted file mode 100644 index b6bcad9a91c66..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require default Deleter ctor - - -#include <memory> - -class Deleter -{ - // expected-error@memory:* {{base class 'Deleter' has private default constructor}} - // expected-note@memory:* + {{in instantiation of member function}} - Deleter() {} // expected-note {{implicitly declared private here}} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) { return *this; } - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp deleted file mode 100644 index 0cc54382b98df..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp deleted file mode 100644 index 3ded41c419c88..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test default unique_ptr<T[]> ctor - -// default unique_ptr<T[]> ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A> > -struct B -{ - std::unique_ptr<A[], D> a_; - B(); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -int main() -{ - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B<Deleter> s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B() {} - -template <class D> -B<D>::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp deleted file mode 100644 index bc49a0e5c31e1..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp deleted file mode 100644 index 5088a4410e792..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5)); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - NCDeleter<A[]> d; - std::unique_ptr<A[], NCDeleter<A[]>&> s(new A[3], d); - A* p = s.get(); - std::unique_ptr<A[], NCDeleter<A[]>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp deleted file mode 100644 index 8e44c78bf1e94..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp deleted file mode 100644 index 89b6fa2488458..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - - -std::unique_ptr<A[]> -source1() -{ - return std::unique_ptr<A[]>(new A[3]); -} - -void sink1(std::unique_ptr<A[]>) -{ -} - -std::unique_ptr<A[], Deleter<A[]> > -source2() -{ - return std::unique_ptr<A[], Deleter<A[]> >(new A[3]); -} - -void sink2(std::unique_ptr<A[], Deleter<A[]> >) -{ -} - -std::unique_ptr<A[], NCDeleter<A[]>&> -source3() -{ - static NCDeleter<A[]> d; - return std::unique_ptr<A[], NCDeleter<A[]>&>(new A[3], d); -} - -void sink3(std::unique_ptr<A[], NCDeleter<A[]>&>) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp deleted file mode 100644 index c952cf2d4e13c..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp deleted file mode 100644 index 0d091ff346d12..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - const std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp deleted file mode 100644 index d175fbf93adc5..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp deleted file mode 100644 index 1838511b49297..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp deleted file mode 100644 index 36ad75d8331a5..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp deleted file mode 100644 index 3a19bde928890..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp deleted file mode 100644 index bda2a70a4ef30..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp deleted file mode 100644 index fba895137b05f..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp deleted file mode 100644 index 24c646988f0a3..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp deleted file mode 100644 index 486d90825d9ef..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp deleted file mode 100644 index e4cbef5c05606..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp deleted file mode 100644 index 73423d1b3751f..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp deleted file mode 100644 index cfc097ba0b841..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp deleted file mode 100644 index fdb088250b9fe..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp deleted file mode 100644 index d9ef8e96fe8fc..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp deleted file mode 100644 index b4577a126c68a..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp deleted file mode 100644 index 9325d07d0d0c1..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp deleted file mode 100644 index b090e593ec62d..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp deleted file mode 100644 index b2af3c7a69385..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp deleted file mode 100644 index d1c0e8a781e67..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp deleted file mode 100644 index 9a8c17547bca8..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp deleted file mode 100644 index 4c31611508315..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor - -#include <memory> - -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp deleted file mode 100644 index dab42f277411b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[]> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp deleted file mode 100644 index 1afb1c32ce8c4..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A[]> > -struct B -{ - std::unique_ptr<A[], D> a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(3); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(3); - B<Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A[3];} - -void Deleter::operator()(A* p) {delete [] p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B(A* a) : a_(a) {} - -template <class D> -B<D>::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp deleted file mode 100644 index 591144f7aa588..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - B* p = new B[3]; - std::unique_ptr<A[]> s(p); - } - { - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 3de556563f97a..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>()); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - - { // LWG#2520 says that nullptr is a valid input as well as null -#ifdef _LIBCPP_VERSION - std::unique_ptr<A[], Deleter<A[]> > s1(NULL, Deleter<A[]>()); -#endif - std::unique_ptr<A[], Deleter<A[]> > s2(nullptr, Deleter<A[]>()); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index a92fdbc1d2c41..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], Deleter> s(nullptr, d); - assert(s.get() == nullptr); - assert(s.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index dd27401731a6d..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], Deleter&> s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index 9d3f94098a08d..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// XFAIL: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T, const D&>(pointer, D()) should not compile - -#include <memory> - -class Deleter -{ -public: - Deleter() {} - void operator()(int* p) const {delete [] p;} -}; - -int main() -{ - int* p = nullptr; - std::unique_ptr<int[], const Deleter&> s(p, Deleter()); // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index 02f44d3575615..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], const Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { - Deleter d; - std::unique_ptr<A[], const Deleter&> s(nullptr, d); - assert(s.get() == nullptr); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp deleted file mode 100644 index 0e03a7da07fb6..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter) should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p, Deleter()); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp deleted file mode 100644 index d79a4e396eeda..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int[3]); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete [] j; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp deleted file mode 100644 index 195d877bbb700..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A[3]); - assert(A::count == 3); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[]> p(new A[4]); - assert(A::count == 4); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A[5]); - assert(A::count == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp deleted file mode 100644 index bca6cb2470ac4..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr<A[]> p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp deleted file mode 100644 index e9754cc0f2266..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1)); - A* p2 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp deleted file mode 100644 index 46ba1395bb857..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int(3)); - assert(*p == 3); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp deleted file mode 100644 index 4496740715a51..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp deleted file mode 100644 index 519eae688ec1b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op[](size_t) - -#include <memory> -#include <cassert> - -class A -{ - int state_; - static int next_; -public: - A() : state_(++next_) {} - int get() const {return state_;} - - friend bool operator==(const A& x, int y) - {return x.state_ == y;} - - A& operator=(int i) {state_ = i; return *this;} -}; - -int A::next_ = 0; - -int main() -{ - std::unique_ptr<A[]> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp deleted file mode 100644 index 380f2e100eb6e..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr::pointer type - -#include <memory> -#include <type_traits> - -#include "test_macros.h" - -struct Deleter -{ - struct pointer {}; -}; - -struct D2 { -private: - typedef void pointer; -}; - -struct D3 { - static long pointer; -}; - -int main() -{ - { - typedef std::unique_ptr<int> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int, Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } -#if TEST_STD_VER >= 11 - { - typedef std::unique_ptr<int, D2> P; - static_assert(std::is_same<P::pointer, int*>::value, ""); - } - { - typedef std::unique_ptr<int, D3> P; - static_assert(std::is_same<P::pointer, int*>::value, ""); - } -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp deleted file mode 100644 index 87cfb72ad6e02..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -// Can't copy from lvalue -int main() -{ - std::unique_ptr<int> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp deleted file mode 100644 index 9535ed0295d46..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s1(new A); - A* p = s1.get(); - std::unique_ptr<A> s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(A::count == 1); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5)); - A* p = s1.get(); - std::unique_ptr<A, Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A> d1(5); - std::unique_ptr<A, CDeleter<A>&> s1(new A, d1); - A* p = s1.get(); - CDeleter<A> d2(6); - std::unique_ptr<A, CDeleter<A>&> s2(new A, d2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp deleted file mode 100644 index 9cea12b1249ff..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -// Can't copy from const lvalue - -int main() -{ - const std::unique_ptr<int> s(new int); - std::unique_ptr<int> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp deleted file mode 100644 index 05a057f9bb325..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from lvalue -int main() -{ - std::unique_ptr<int, Deleter> s, s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - s2 = s; // expected-error {{'operator=' is a private member}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp deleted file mode 100644 index 24703ec98238e..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> - -#include "test_macros.h" - -struct Deleter { - void operator()(int* p) {delete p;} -}; - -// Can't copy from a const lvalue -int main() -{ - const std::unique_ptr<int, Deleter> s(new int); - std::unique_ptr<int, Deleter> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp deleted file mode 100644 index 4c4a320356410..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -template <class APtr, class BPtr> -void testAssign(APtr& aptr, BPtr& bptr) { - A* p = bptr.get(); - assert(A::count == 2); - aptr = std::move(bptr); - assert(aptr.get() == p); - assert(bptr.get() == 0); - assert(A::count == 1); - assert(B::count == 1); -} - -template <class LHS, class RHS> -void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { - assert(lhs.get_deleter().state() == LHSState); - assert(rhs.get_deleter().state() == RHSState); -} - -int main() -{ - { - std::unique_ptr<B> bptr(new B); - std::unique_ptr<A> aptr(new A); - testAssign(aptr, bptr); - } - assert(A::count == 0); - assert(B::count == 0); - { - Deleter<B> del(42); - std::unique_ptr<B, Deleter<B> > bptr(new B, std::move(del)); - std::unique_ptr<A, Deleter<A> > aptr(new A); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 0); - } - assert(A::count == 0); - assert(B::count == 0); - { - CDeleter<A> adel(6); - CDeleter<B> bdel(42); - std::unique_ptr<B, CDeleter<B>&> bptr(new B, bdel); - std::unique_ptr<A, CDeleter<A>&> aptr(new A, adel); - testAssign(aptr, bptr); - checkDeleter(aptr, bptr, 42, 42); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp deleted file mode 100644 index 816a598d9a237..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr<B> s; - std::unique_ptr<A> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp deleted file mode 100644 index 1ddf1d811651c..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp deleted file mode 100644 index 570c1c42f4fe3..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - Deleter<B> db; - std::unique_ptr<B, Deleter<B>& > s(new B, db); - Deleter<A> da; - std::unique_ptr<A, Deleter<A> &> s2(new A, da); -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The move-semantic emulation creates an ambiguous overload set - // so that assignment from an lvalue does not compile - s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp deleted file mode 100644 index 2ebc33d21d81e..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> - -#include "test_macros.h" -#include "../../deleter.h" - -struct A -{ - A() {} - virtual ~A() {} -}; - -struct B : public A -{ -}; - -// Can't assign from lvalue -int main() -{ - const std::unique_ptr<B> s(new B); - std::unique_ptr<A> s2; -#if TEST_STD_VER >= 11 - s2 = s; // expected-error {{no viable overloaded '='}} -#else - // NOTE: The error says "constructor" because the assignment operator takes - // 's' by value and attempts to copy construct it. - s2 = s; // expected-error {{no matching constructor for initialization}} -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp deleted file mode 100644 index 4694986c67730..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp deleted file mode 100644 index 220677cd6fa77..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const std::unique_ptr<B, Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - std::unique_ptr<A, Deleter<A>&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp deleted file mode 100644 index 412648420d46d..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Do not convert from an array unique_ptr - -#include <memory> -#include <utility> -#include <cassert> - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2; - s2 = std::move(s); // expected-error {{no viable overloaded '='}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp deleted file mode 100644 index 7c3ac462c2876..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// libc++ cannot safely provide the auto_ptr constructor without rvalue -// references. -// XFAIL: c++98, c++03 - -// <memory> - -// unique_ptr - -// template <class U> unique_ptr(auto_ptr<U>&&) noexcept - -#include <memory> -#include <utility> -#include <cassert> - -#include "test_macros.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(std::move(ap)); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = std::move(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -#if TEST_STD_VER >= 11 - { - static_assert(std::is_nothrow_constructible< - std::unique_ptr<A>, - std::auto_ptr<B>&& - >::value, ""); - } -#endif -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp deleted file mode 100644 index 1f317c7824542..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B -// : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = ap; - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp deleted file mode 100644 index 2dd5ea30049b8..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct Deleter -{ - template <class T> - void operator()(T*) {} -}; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A, Deleter> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp deleted file mode 100644 index 2694538145b90..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The default constructor works for any default constructible deleter types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Default construct unique_ptr's with various deleter types (C-1) -// 2 Default construct a unique_ptr with a incomplete element_type and -// various deleter types (C-1,2) - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct IncompleteT; - -void checkNumIncompleteTypeAlive(int i); - -template <class Del = std::default_delete<IncompleteT> > -struct StoresIncomplete { - std::unique_ptr<IncompleteT, Del> m_ptr; - StoresIncomplete() {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -int main() -{ - { - std::unique_ptr<int> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int, NCDeleter<int> > p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 0); - p.get_deleter().set_state(5); - assert(p.get_deleter().state() == 5); - } - { - StoresIncomplete<> s; - assert(s.get() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); - { - StoresIncomplete< Deleter<IncompleteT> > s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 0); - checkNumIncompleteTypeAlive(0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template <class Del> -StoresIncomplete<Del>::~StoresIncomplete() { }
\ No newline at end of file diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp deleted file mode 100644 index 2ffe1be190e0b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp deleted file mode 100644 index 690750143414b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp deleted file mode 100644 index 78f6e73a1d55c..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp deleted file mode 100644 index 4c5cc843a138c..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -//============================================================================= -// TESTING unique_ptr(unique_ptr&&) -// -// Concerns -// 1 The moved from pointer is empty and the new pointer stores the old value. -// 2 The only requirement on the deleter is that it is MoveConstructible -// or a reference. -// 3 The constructor works for explicitly moved values (ie std::move(x)) -// 4 The constructor works for true temporaries (ie a return value) -// -// Plan -// 1 Explicitly construct unique_ptr<T, D> for various deleter types 'D'. -// check that the value and deleter have been properly moved. (C-1,2,3) -// -// 2 Use the expression 'sink(source())' to move construct a unique_ptr<T, D> -// from a temporary. 'source' should return the unique_ptr by value and -// 'sink' should accept the unique_ptr by value. (C-1,2,4) - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -template <class Expect> -void sinkFunction(Expect) -{ -} - -typedef std::unique_ptr<A> APtrSource1; -typedef std::unique_ptr<A, Deleter<A> > APtrSource2; -typedef std::unique_ptr<A, NCDeleter<A>& > APtrSource3; - -APtrSource1 source1() { - return APtrSource1 (new A); -} - -void sink1(APtrSource1 p) { - assert(p.get() != nullptr); -} - -APtrSource2 source2() { - return APtrSource2(new A, Deleter<A>(5)); -} - -void sink2(APtrSource2 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); -} - -APtrSource3 source3() { - static NCDeleter<A> d(5); - return APtrSource3(new A, d); -} - -void sink3(APtrSource3 p) { - assert(p.get() != nullptr); - assert(p.get_deleter().state() == 5); - assert(&p.get_deleter() == &source3().get_deleter()); -} - -int main() -{ - { - typedef std::unique_ptr<A> APtr; - APtr s(new A); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); - { - typedef Deleter<A> MoveDel; - typedef std::unique_ptr<A, MoveDel> APtr; - MoveDel d(5); - APtr s(new A, std::move(d)); - assert(d.state() == 0); - assert(s.get_deleter().state() == 5); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - typedef NCDeleter<A> NonCopyDel; - typedef std::unique_ptr<A, NonCopyDel&> APtr; - - NonCopyDel d; - APtr s(new A, d); - A* p = s.get(); - APtr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - { - sink1(source1()); - assert(A::count == 0); - sink2(source2()); - assert(A::count == 0); - sink3(source3()); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp deleted file mode 100644 index 68ad589b11480..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp deleted file mode 100644 index 897b889d67789..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp deleted file mode 100644 index 7fb1a0a748114..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp deleted file mode 100644 index 671e343fd7f5d..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp deleted file mode 100644 index f00fcfe15b808..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp +++ /dev/null @@ -1,171 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// - -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// NOTE: unique_ptr does not provide converting constructors in c++03 -// XFAIL: c++98, c++03 - - - -#include <memory> -#include <type_traits> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -template <class LHS, class RHS> -void checkReferenceDeleter(LHS& lhs, RHS& rhs) { - typedef typename LHS::deleter_type NewDel; - static_assert(std::is_reference<NewDel>::value, ""); - rhs.get_deleter().set_state(42); - assert(rhs.get_deleter().state() == 42); - assert(lhs.get_deleter().state() == 42); - lhs.get_deleter().set_state(99); - assert(lhs.get_deleter().state() == 99); - assert(rhs.get_deleter().state() == 99); -} - -template <class LHS, class RHS> -void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { - assert(lhs.get_deleter().state() == LHSVal); - assert(rhs.get_deleter().state() == RHSVal); -} - -template <class LHS, class RHS> -void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { - assert(lhs.get() == RHSVal); - assert(rhs.get() == nullptr); - assert(A::count == 1); - assert(B::count == 1); -} - -void checkNoneAlive() { - assert(A::count == 0); - assert(B::count == 0); -} - -int main() -{ - { - typedef std::unique_ptr<A> APtr; - typedef std::unique_ptr<B> BPtr; - { // explicit - BPtr b(new B); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - } - checkNoneAlive(); - { // implicit - BPtr b(new B); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - } - checkNoneAlive(); - } - { // test with moveable deleters - typedef std::unique_ptr<A, Deleter<A> > APtr; - typedef std::unique_ptr<B, Deleter<B> > BPtr; - { - Deleter<B> del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - { - Deleter<B> del(5); - BPtr b(new B, std::move(del)); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 0); - } - checkNoneAlive(); - - } - { // test with reference deleters - typedef std::unique_ptr<A, NCDeleter<A>& > APtr; - typedef std::unique_ptr<B, NCDeleter<A>& > BPtr; - NCDeleter<A> del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkReferenceDeleter(a, b); - } - checkNoneAlive(); - } - { - typedef std::unique_ptr<A, CDeleter<A> > APtr; - typedef std::unique_ptr<B, CDeleter<B>& > BPtr; - CDeleter<B> del(5); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a(std::move(b)); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - { - BPtr b(new B, del); - A* p = b.get(); - APtr a = std::move(b); - checkCtor(a, b, p); - checkDeleter(a, b, 5, 5); - } - checkNoneAlive(); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp deleted file mode 100644 index ed1fe8c2bdd4b..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// Can't construct from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp deleted file mode 100644 index a1bf634b9995e..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp deleted file mode 100644 index 7409199791b56..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp deleted file mode 100644 index 981ea706eb293..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp deleted file mode 100644 index d055b80627f91..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - std::unique_ptr<B, Deleter<B> > s(new B); - std::unique_ptr<A, Deleter<A> > s2 = s; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp deleted file mode 100644 index 5b9b12e0d60ba..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp deleted file mode 100644 index bef022cfc1434..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp deleted file mode 100644 index 016eadcb24607..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class Deleter -{ - int state_; - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); - -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template <class U> - Deleter(Deleter<U>&& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template <class U> - Deleter(const Deleter<U>& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2(s); // expected-error {{no matching constructor}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp deleted file mode 100644 index a475c17547c92..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp deleted file mode 100644 index f0da5efb69174..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp deleted file mode 100644 index 1b8bb736df200..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } - - Deleter() : state_(5) {} - - template <class U> - Deleter(Deleter<U>&& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template <class U> - Deleter(const Deleter<U>& d, - typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); - -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - const std::unique_ptr<B, Deleter<B> > s; - std::unique_ptr<A, Deleter<A> > s2 = s; // expected-error {{no viable conversion}} -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp deleted file mode 100644 index 095bec65669b3..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <utility> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp deleted file mode 100644 index 67a48a3e7a12f..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int, Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp deleted file mode 100644 index faa554d8b3209..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING std::unique_ptr::unique_ptr() -// -// Concerns: -// 1 The pointer constructor works for any default constructible deleter types. -// 2 The pointer constructor accepts pointers to derived types. -// 2 The stored type 'T' is allowed to be incomplete. -// -// Plan -// 1 Construct unique_ptr<T, D>'s with a pointer to 'T' and various deleter -// types (C-1) -// 2 Construct unique_ptr<T, D>'s with a pointer to 'D' and various deleter -// types where 'D' is derived from 'T'. (C-1,2) -// 3 Construct a unique_ptr<T, D> with a pointer to 'T' and various deleter -// types where 'T' is an incomplete type (C-1,3) - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - - -struct IncompleteT; - -IncompleteT* getIncomplete(); -void checkNumIncompleteTypeAlive(int i); - -template <class Del = std::default_delete<IncompleteT> > -struct StoresIncomplete { - std::unique_ptr<IncompleteT, Del> m_ptr; - StoresIncomplete() {} - explicit StoresIncomplete(IncompleteT* ptr) : m_ptr(ptr) {} - ~StoresIncomplete(); - - IncompleteT* get() const { return m_ptr.get(); } - Del& get_deleter() { return m_ptr.get_deleter(); } -}; - -void test_pointer() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, NCDeleter<A> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); -} - -void test_derived() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, NCDeleter<A> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} - -void test_incomplete() -{ - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete<> s(p); - assert(s.get() == p); - } - checkNumIncompleteTypeAlive(0); - { - IncompleteT* p = getIncomplete(); - checkNumIncompleteTypeAlive(1); - StoresIncomplete< NCDeleter<IncompleteT> > s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - checkNumIncompleteTypeAlive(0); -} - -struct IncompleteT { - static int count; - IncompleteT() { ++count; } - ~IncompleteT() {--count; } -}; - -int IncompleteT::count = 0; - -IncompleteT* getIncomplete() { - return new IncompleteT; -} - -void checkNumIncompleteTypeAlive(int i) { - assert(IncompleteT::count == i); -} - -template <class Del> -StoresIncomplete<Del>::~StoresIncomplete() { } - -int main() -{ - test_pointer(); - test_derived(); - test_incomplete(); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp deleted file mode 100644 index 1af04b2c00338..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp deleted file mode 100644 index 9b7dd8c70f280..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp deleted file mode 100644 index a917d87eeeded..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p(new int); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp deleted file mode 100644 index 7ddd162651078..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -//============================================================================= -// TESTING unique_ptr(pointer, deleter) -// -// Concerns: -// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. -// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. -// 3 unique_ptr<T, D&>(pointer, deleter) does not require a CopyConstructible deleter. -// 4 unique_ptr<T, D const&>(pointer, deleter) does not require a CopyConstructible deleter. -// 5 unique_ptr(pointer, deleter) should work for derived pointers. -// 6 unique_ptr(pointer, deleter) should work with function pointers. -// 7 unique_ptr<void> should work. - - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -bool my_free_called = false; - -void my_free(void*) { - my_free_called = true; -} - -int main() -{ - { // MoveConstructible deleter (C-1) - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // CopyConstructible deleter (C-2) - A* p = new A; - assert(A::count == 1); - CopyDeleter<A> d(5); - std::unique_ptr<A, CopyDeleter<A> > s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - { // Reference deleter (C-3) - A* p = new A; - assert(A::count == 1); - NCDeleter<A> d(5); - std::unique_ptr<A, NCDeleter<A>&> s(p, d); - assert(s.get() == p); - assert(&s.get_deleter() == &d); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); - { // Const Reference deleter (C-4) - A* p = new A; - assert(A::count == 1); - NCConstDeleter<A> d(5); - std::unique_ptr<A, NCConstDeleter<A> const&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - assert(&s.get_deleter() == &d); - } - assert(A::count == 0); - { // Derived pointers (C-5) - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); - { // Void and function pointers (C-6,7) - { - int i = 0; - std::unique_ptr<void, void(*)(void*)> s(&i, my_free); - assert(s.get() == &i); - assert(s.get_deleter() == my_free); - assert(!my_free_called); - } - assert(my_free_called); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp deleted file mode 100644 index dadd4ecbe5901..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int> p(new int(3)); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete j; -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp deleted file mode 100644 index 2cf7f8b775683..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - assert(i != nullptr); - p.reset(new A); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp deleted file mode 100644 index d0a03be803269..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1)); - A* p2 = new A(2); - std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp deleted file mode 100644 index 24fa6beb42733..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get - -#include <memory> -#include <cassert> - -int main() -{ - int* p = new int; - std::unique_ptr<int> s(p); - assert(s.get() == p); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp deleted file mode 100644 index 5ed8a22b14c45..0000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp index b9f8ee0746c31..5a0d9259c11d4 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp @@ -51,11 +51,11 @@ struct Bar : public Foo { int main() { - { // https://llvm.org/bugs/show_bug.cgi?id=18843 + { // https://bugs.llvm.org/show_bug.cgi?id=18843 std::shared_ptr<T const> t1(new T); std::shared_ptr<T const> t2(std::make_shared<T>()); } - { // https://llvm.org/bugs/show_bug.cgi?id=27115 + { // https://bugs.llvm.org/show_bug.cgi?id=27115 int x = 42; std::shared_ptr<Bar> t1(new Bar(42)); assert(t1->shared_from_this() == t1); @@ -84,12 +84,12 @@ int main() T* ptr = new T; std::shared_ptr<T> s(ptr); { - // Don't re-initialize the "enabled_shared_from_this" base + // Don't re-initialize the "enable_shared_from_this" base // because it already references a non-expired shared_ptr. std::shared_ptr<T> s2(ptr, &nullDeleter); } #if TEST_STD_VER > 14 - // The enabled_shared_from_this base should still be referencing + // The enable_shared_from_this base should still be referencing // the original shared_ptr. assert(!ptr->weak_from_this().expired()); #endif diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp index 31f7ce367e3dc..e9237c534fba5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// -// <memory> - -// unique_ptr +// UNSUPPORTED: c++98, c++03 -// Test unique_ptr<T[]>(pointer) ctor +// <memory> -// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter +// Test that <memory> provides all of the arithmetic, enum, and pointer +// hash specializations. #include <memory> -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p(new int); +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp index 990cb58722b1c..5fba1fc0460ba 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp @@ -20,11 +20,25 @@ #include <memory> #include <cassert> +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" + +struct A {}; +#endif + int main() { + { int* ptr = new int; std::shared_ptr<int> p(ptr); std::hash<std::shared_ptr<int> > f; std::size_t h = f(p); assert(h == std::hash<int*>()(ptr)); + } +#if TEST_STD_VER >= 11 + { + test_hash_enabled_for_type<std::shared_ptr<int>>(); + test_hash_enabled_for_type<std::shared_ptr<A>>(); + } +#endif } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp index 5cd4ab1f83d0e..fc346d4dce7df 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp @@ -20,11 +20,80 @@ #include <memory> #include <cassert> +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" +#include "deleter_types.h" +#include "min_allocator.h" + +template <class ValueT, class Del> +void test_enabled_with_deleter() { + using UPtr = std::unique_ptr<ValueT, Del>; + using pointer = typename UPtr::pointer; + using RawDel = typename std::decay<Del>::type; + RawDel d(1); + UPtr p(nullptr, std::forward<Del>(d)); + test_hash_enabled_for_type<UPtr>(p); + test_hash_enabled_for_type<pointer>(); +} + +template <class ValueT, class Del> +void test_disabled_with_deleter() { + using UPtr = std::unique_ptr<ValueT, Del>; + using pointer = typename UPtr::pointer; + test_hash_disabled_for_type<UPtr>(); + test_hash_disabled_for_type<pointer>(); +} + +namespace std { + +template <class T> +struct hash<::min_pointer<T, std::integral_constant<size_t, 1>>> { + size_t operator()(::min_pointer<T, std::integral_constant<size_t, 1>> p) const noexcept(false) { + if (!p) return 0; + return std::hash<T*>{}(std::addressof(*p)); + } +}; +} + +struct A {}; + +#endif // TEST_STD_VER >= 11 + int main() { + { int* ptr = new int; std::unique_ptr<int> p(ptr); std::hash<std::unique_ptr<int> > f; + ASSERT_NOT_NOEXCEPT(f(p)); std::size_t h = f(p); assert(h == std::hash<int*>()(ptr)); + } +#if TEST_STD_VER >= 11 + { + test_enabled_with_deleter<int, Deleter<int>>(); + test_enabled_with_deleter<int[], Deleter<int[]>>(); + test_enabled_with_deleter<int, CopyDeleter<int>>(); + test_enabled_with_deleter<int, CopyDeleter<int[]>>(); + test_enabled_with_deleter<int, NCDeleter<int>&>(); + test_enabled_with_deleter<int[], NCDeleter<int[]>&>(); + test_enabled_with_deleter<int, NCConstDeleter<int> const&>(); + test_enabled_with_deleter<int[], NCConstDeleter<int[]> const&>(); + } + { + test_enabled_with_deleter<int, PointerDeleter<int, 1>>(); + test_enabled_with_deleter<int[], PointerDeleter<int[], 1>>(); + test_enabled_with_deleter<A, PointerDeleter<A, 1>>(); + test_enabled_with_deleter<A[], PointerDeleter<A[], 1>>(); + +#if TEST_STD_VER > 14 + test_disabled_with_deleter<int, PointerDeleter<int, 0>>(); + test_disabled_with_deleter<int[], PointerDeleter<int[], 0>>(); + test_disabled_with_deleter<A, PointerDeleter<A, 0>>(); + test_disabled_with_deleter<A[], PointerDeleter<A[], 0>>(); +#endif + } +#endif } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp index 3bad537e34315..d1e13139bce36 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp index 5cc1234ad34ee..08e31e8d7d700 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp index a89c0dbd2207c..f8f550deb0513 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp index 821cea6868e48..1ea11ceed43d9 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp index 66be756d54fd6..9a5792f519d5f 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp index 493ba7fcc94d0..aac9af082d74e 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp index 4820d05420a2f..fa79e7cdd9ad4 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp index ef8dc822102ff..c650899f764ac 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp index a13a7d57ab960..cbcc4ddbbc2ca 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp index 6dfe3166c8c58..eb5e246833c2b 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp @@ -11,8 +11,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // <memory> diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h deleted file mode 100644 index 6b3f1e2ab0dea..0000000000000 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// Example move-only deleter - -#ifndef DELETER_H -#define DELETER_H - -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -#if TEST_STD_VER >= 11 -#define DELETE_FUNCTION = delete -#else -#define DELETE_FUNCTION { assert(false); } -#endif - -struct test_deleter_base -{ - static int count; - static int dealloc_count; -}; - -int test_deleter_base::count = 0; -int test_deleter_base::dealloc_count = 0; - -template <class T> -class test_deleter - : public test_deleter_base -{ - int state_; - -public: - - test_deleter() : state_(0) {++count;} - explicit test_deleter(int s) : state_(s) {++count;} - test_deleter(const test_deleter& d) - : state_(d.state_) {++count;} - ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;} - - test_deleter* operator&() const DELETE_FUNCTION; -}; - -template <class T> -void -swap(test_deleter<T>& x, test_deleter<T>& y) -{ - test_deleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -#endif // DELETER_H diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp index a6c62496fd62f..05a199cced639 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp index 21cdf4a13e476..10d53c1268aa2 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp @@ -10,6 +10,7 @@ // <memory> // shared_ptr +// REQUIRES: c++98 || c++03 || c++11 || c++14 // template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp index f8fdb7a094782..3ad3232a90b41 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp @@ -10,6 +10,7 @@ // <memory> // template<class Y> explicit shared_ptr(auto_ptr<Y>&& r); +// REQUIRES: c++98 || c++03 || c++11 || c++14 #include <memory> @@ -85,6 +86,7 @@ int main() // Without rvalue references, ptr got copied into // the shared_ptr destructor and the copy was // destroyed during unwinding. + (void) raw_ptr; // silence 'unused variable' warning assert(A::count == 0); assert(B::count == 0); #endif diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp index 7d4dc38d4b9a0..bf2a304011c8d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp index 8a6cd0f352ff7..aabc66a03c40e 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp @@ -13,7 +13,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" #include "min_allocator.h" diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp index 2e6441d663160..55e52f49c752c 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp @@ -14,7 +14,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct A diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp index 009b4cfc00f9a..e82f0fdcc9ed8 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp @@ -24,7 +24,7 @@ #include "test_macros.h" #include "count_new.hpp" -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp index 43eedee176c2c..c813f6f6f9c5a 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp index b0facfc1a6eb5..96a1779fe870e 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp @@ -13,7 +13,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" #include "min_allocator.h" diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp index 388599bd70157..47d24c349871b 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp @@ -14,7 +14,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct A diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp index 7b40d6df2164b..13c2d435b93a7 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp @@ -22,7 +22,7 @@ #include <cstdlib> #include "count_new.hpp" -#include "../test_deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp index 877577c9ce58a..17289197d35e3 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp @@ -80,6 +80,7 @@ int main() assert(B::count == 1); assert(ptr.get() == raw_ptr); #else + (void) raw_ptr; // silence 'unused variable' warning assert(A::count == 0); assert(B::count == 0); assert(ptr.get() == 0); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp index 8d782716b94f0..2a7ac9979d025 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -59,7 +59,7 @@ int main() assert(p->get_char() == 'e'); } - { // https://llvm.org/bugs/show_bug.cgi?id=24137 + { // https://bugs.llvm.org/show_bug.cgi?id=24137 std::shared_ptr<Foo> p1 = std::make_shared<Foo>(); assert(p1.get()); std::shared_ptr<const Foo> p2 = std::make_shared<const Foo>(); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp index 33965dfeb33c0..c33133d79fdc8 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" struct B { diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp index 09070e2c059b0..58262eb4334eb 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp @@ -15,7 +15,7 @@ #include <memory> #include <cassert> -#include "../test_deleter.h" +#include "deleter_types.h" #include "test_allocator.h" struct B diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp index 3acd2f8c6f2d4..9f6f1bc75c71a 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template <class U> bool owner_before(shared_ptr<U> const& b) const; +// template <class U> bool owner_before(shared_ptr<U> const& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -25,4 +26,5 @@ int main() assert(!p2.owner_before(p1)); assert(p1.owner_before(p3) || p3.owner_before(p1)); assert(p3.owner_before(p1) == p3.owner_before(p2)); + ASSERT_NOEXCEPT(p1.owner_before(p2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp index 33447ba7da00f..560293bbedb7c 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // shared_ptr -// template <class U> bool owner_before(weak_ptr<U> const& b) const; +// template <class U> bool owner_before(weak_ptr<U> const& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,5 @@ int main() assert(!p2.owner_before(w1)); assert(p1.owner_before(w3) || p3.owner_before(w1)); assert(p3.owner_before(w1) == p3.owner_before(w2)); + ASSERT_NOEXCEPT(p1.owner_before(w2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp index 142eba2d96478..7ab60da77c7d7 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp @@ -16,9 +16,9 @@ // : binary_function<shared_ptr<T>, shared_ptr<T>, bool> // { // typedef bool result_type; -// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; +// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept; +// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept; // }; // // template <class T> @@ -26,22 +26,22 @@ // : binary_function<weak_ptr<T>, weak_ptr<T>, bool> // { // typedef bool result_type; -// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; +// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept; +// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept; // }; // // Added in C++17 // template<> struct owner_less<void> // { // template<class T, class U> -// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const; +// bool operator()(shared_ptr<T> const&, shared_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const; +// bool operator()(shared_ptr<T> const&, weak_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const; +// bool operator()(weak_ptr<T> const&, shared_ptr<U> const&) const noexcept; // template<class T, class U> -// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const; +// bool operator()(weak_ptr<T> const&, weak_ptr<U> const&) const noexcept; // // typedef unspecified is_transparent; // }; @@ -69,16 +69,19 @@ int main() static_assert((std::is_same<std::shared_ptr<int>, CS::first_argument_type>::value), "" ); static_assert((std::is_same<std::shared_ptr<int>, CS::second_argument_type>::value), "" ); static_assert((std::is_same<bool, CS::result_type>::value), "" ); - + assert(!cs(p1, p2)); assert(!cs(p2, p1)); assert(cs(p1 ,p3) || cs(p3, p1)); assert(cs(p3, p1) == cs(p3, p2)); + ASSERT_NOEXCEPT(cs(p1, p1)); assert(!cs(p1, w2)); assert(!cs(p2, w1)); assert(cs(p1, w3) || cs(p3, w1)); assert(cs(p3, w1) == cs(p3, w2)); + ASSERT_NOEXCEPT(cs(p1, w1)); + ASSERT_NOEXCEPT(cs(w1, p1)); } { typedef std::owner_less<std::weak_ptr<int> > CS; @@ -92,11 +95,14 @@ int main() assert(!cs(w2, w1)); assert(cs(w1, w3) || cs(w3, w1)); assert(cs(w3, w1) == cs(w3, w2)); + ASSERT_NOEXCEPT(cs(w1, w1)); assert(!cs(w1, p2)); assert(!cs(w2, p1)); assert(cs(w1, p3) || cs(w3, p1)); assert(cs(w3, p1) == cs(w3, p2)); + ASSERT_NOEXCEPT(cs(w1, p1)); + ASSERT_NOEXCEPT(cs(p1, w1)); } #if TEST_STD_VER > 14 { @@ -111,6 +117,10 @@ int main() cmp(sp1, sp3); cmp(wp1, sp1); cmp(wp1, wp1); + ASSERT_NOEXCEPT(cmp(sp1, sp1)); + ASSERT_NOEXCEPT(cmp(sp1, wp1)); + ASSERT_NOEXCEPT(cmp(wp1, sp1)); + ASSERT_NOEXCEPT(cmp(wp1, wp1)); } { // test heterogeneous lookups diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp index 4aa49cfe8a24d..458f8a11ed120 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template<class U> bool owner_before(const shared_ptr<U>& b); +// template<class U> bool owner_before(const shared_ptr<U>& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(p1)); assert(w1.owner_before(p3) || w3.owner_before(p1)); assert(w3.owner_before(p1) == w3.owner_before(p2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(p2)); } diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp index 9fe2b6e390350..5cd171a53021d 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp @@ -11,10 +11,11 @@ // weak_ptr -// template<class U> bool owner_before(const weak_ptr<U>& b); +// template<class U> bool owner_before(const weak_ptr<U>& b) const noexcept; #include <memory> #include <cassert> +#include "test_macros.h" int main() { @@ -28,4 +29,6 @@ int main() assert(!w2.owner_before(w1)); assert(w1.owner_before(w3) || w3.owner_before(w1)); assert(w3.owner_before(w1) == w3.owner_before(w2)); +// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted + LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(w2)); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 61523e4872d46..85b14726617f8 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -37,8 +37,16 @@ namespace std typedef S<T> type; }; +// P0548 + template <class T> + struct common_type< ::S<T>, ::S<T> > { + typedef S<T> type; + }; + template <> struct common_type< ::S<long>, long> {}; template <> struct common_type<long, ::S<long> > {}; + template <> struct common_type< ::X<float> > {}; + template <> struct common_type< ::X<double>, ::X<double> > {}; } #if TEST_STD_VER >= 11 @@ -88,6 +96,9 @@ void test_bullet_two() { static_assert(std::is_same<CommonType<int const>, int>::value, ""); static_assert(std::is_same<CommonType<int volatile[]>, int volatile*>::value, ""); static_assert(std::is_same<CommonType<void(&)()>, void(*)()>::value, ""); + + static_assert(no_common_type<X<float> >::value, ""); + static_assert(no_common_type<X<double> >::value, ""); } template <class T, class U, class Expect> @@ -284,4 +295,18 @@ int main() test_bullet_three_two(); test_bullet_four(); #endif + +// P0548 + static_assert((std::is_same<std::common_type<S<int> >::type, S<int> >::value), ""); + static_assert((std::is_same<std::common_type<S<int>, S<int> >::type, S<int> >::value), ""); + + static_assert((std::is_same<std::common_type<int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<volatile int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), ""); + + static_assert((std::is_same<std::common_type<int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int, int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), ""); + static_assert((std::is_same<std::common_type<const int, const int>::type, int>::value), ""); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp index bcd8398494533..4f45a0340a916 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -33,4 +33,10 @@ int main() test_decay<int[3], int*>(); test_decay<const int[3], const int*>(); test_decay<void(), void (*)()>(); +#if TEST_STD_VER > 11 + test_decay<int(int) const, int(int) const>(); + test_decay<int(int) volatile, int(int) volatile>(); + test_decay<int(int) &, int(int) &>(); + test_decay<int(int) &&, int(int) &&>(); +#endif } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp index 8cb5853bbc6d7..eac4e4a089fed 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp @@ -26,7 +26,6 @@ struct wat struct F {}; struct FD : public F {}; -struct NotDerived {}; template <class T, class U> void test_result_of_imp() @@ -43,7 +42,6 @@ void test_result_of_imp() int main() { - typedef NotDerived ND; { typedef char F::*PMD; test_result_of_imp<PMD(F &), char &>(); diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp index 410e47e03bcc2..b00798b72240c 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -17,24 +17,32 @@ #include "test_macros.h" enum E { V = INT_MIN }; -enum F { W = UINT_MAX }; -int main() -{ #if !defined(_WIN32) || defined(__MINGW32__) - typedef unsigned ExpectUnsigned; + #define TEST_UNSIGNED_UNDERLYING_TYPE 1 #else - typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard + #define TEST_UNSIGNED_UNDERLYING_TYPE 0 // MSVC's ABI doesn't follow the Standard #endif + +#if TEST_UNSIGNED_UNDERLYING_TYPE +enum F { W = UINT_MAX }; +#endif // TEST_UNSIGNED_UNDERLYING_TYPE + +int main() +{ static_assert((std::is_same<std::underlying_type<E>::type, int>::value), "E has the wrong underlying type"); - static_assert((std::is_same<std::underlying_type<F>::type, ExpectUnsigned>::value), +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value), "F has the wrong underlying type"); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE #if TEST_STD_VER > 11 static_assert((std::is_same<std::underlying_type_t<E>, int>::value), ""); - static_assert((std::is_same<std::underlying_type_t<F>, ExpectUnsigned>::value), ""); -#endif +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE +#endif // TEST_STD_VER > 11 #if TEST_STD_VER >= 11 enum G : char { }; @@ -43,6 +51,6 @@ int main() "G has the wrong underlying type"); #if TEST_STD_VER > 11 static_assert((std::is_same<std::underlying_type_t<G>, char>::value), ""); -#endif +#endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 } diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp index 05ef99d0ebf4d..2d10fb0040a7e 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -13,7 +13,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// XFAIL: gcc-5.1 gcc-5.2 +// XFAIL: gcc-5.1, gcc-5.2 #include <type_traits> diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp index 32e4f06beb04e..c340ba69cda3c 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp @@ -13,6 +13,7 @@ #include <type_traits> #include <cstddef> // for std::nullptr_t + #include "test_macros.h" template <class T> @@ -79,22 +80,27 @@ int main() test_is_function<int(Abstract *)>(); test_is_function<void(...)>(); - test_is_not_function<std::nullptr_t>(); - test_is_not_function<void>(); - test_is_not_function<int>(); - test_is_not_function<int&>(); - test_is_not_function<int&&>(); - test_is_not_function<int*>(); - test_is_not_function<double>(); - test_is_not_function<char[3]>(); - test_is_not_function<char[]>(); - test_is_not_function<Union>(); - test_is_not_function<Enum>(); - test_is_not_function<FunctionPtr>(); // function pointer is not a function - test_is_not_function<Empty>(); - test_is_not_function<bit_zero>(); - test_is_not_function<NotEmpty>(); - test_is_not_function<Abstract>(); - test_is_not_function<Abstract*>(); - test_is_not_function<incomplete_type>(); + test_is_not_function<std::nullptr_t>(); + test_is_not_function<void>(); + test_is_not_function<int>(); + test_is_not_function<int&>(); + test_is_not_function<int&&>(); + test_is_not_function<int*>(); + test_is_not_function<double>(); + test_is_not_function<char[3]>(); + test_is_not_function<char[]>(); + test_is_not_function<Union>(); + test_is_not_function<Enum>(); + test_is_not_function<FunctionPtr>(); // function pointer is not a function + test_is_not_function<Empty>(); + test_is_not_function<bit_zero>(); + test_is_not_function<NotEmpty>(); + test_is_not_function<Abstract>(); + test_is_not_function<Abstract*>(); + test_is_not_function<incomplete_type>(); + +#if TEST_STD_VER >= 11 + test_is_function<void() noexcept>(); + test_is_function<void() const && noexcept>(); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp index d4043f48f98ed..a63a88c4d18bd 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp @@ -97,4 +97,10 @@ int main() test_is_not_member_pointer<NotEmpty>(); test_is_not_member_pointer<Abstract>(); test_is_not_member_pointer<incomplete_type>(); + +#if TEST_STD_VER >= 11 + test_is_member_pointer<int (Empty::*)(int, ...) const>(); + test_is_member_pointer<int (Empty::*)(int, long, long) const noexcept>(); + test_is_member_pointer<int (Empty::*)() & noexcept>(); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp index a895a8d447b66..691c549b5e78b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -52,90 +52,175 @@ struct incomplete_type; int main() { - test_member_function_pointer<void (Class::*)()>(); - test_member_function_pointer<void (Class::*)(int)>(); - test_member_function_pointer<void (Class::*)(int, char)>(); + test_member_function_pointer<void (Class::*)()>(); + test_member_function_pointer<void (Class::*)(int)>(); + test_member_function_pointer<void (Class::*)(int, char)>(); - test_member_function_pointer<void (Class::*)() const>(); - test_member_function_pointer<void (Class::*)(int) const>(); - test_member_function_pointer<void (Class::*)(int, char) const>(); + test_member_function_pointer<void (Class::*)() const>(); + test_member_function_pointer<void (Class::*)(int) const>(); + test_member_function_pointer<void (Class::*)(int, char) const>(); - test_member_function_pointer<void (Class::*)() volatile>(); - test_member_function_pointer<void (Class::*)(int) volatile>(); - test_member_function_pointer<void (Class::*)(int, char) volatile>(); + test_member_function_pointer<void (Class::*)() volatile>(); + test_member_function_pointer<void (Class::*)(int) volatile>(); + test_member_function_pointer<void (Class::*)(int, char) volatile>(); - test_member_function_pointer<void (Class::*)(...)>(); - test_member_function_pointer<void (Class::*)(int, ...)>(); - test_member_function_pointer<void (Class::*)(int, char, ...)>(); + test_member_function_pointer<void (Class::*)(...)>(); + test_member_function_pointer<void (Class::*)(int, ...)>(); + test_member_function_pointer<void (Class::*)(int, char, ...)>(); - test_member_function_pointer<void (Class::*)(...) const>(); - test_member_function_pointer<void (Class::*)(int, ...) const>(); - test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + test_member_function_pointer<void (Class::*)(...) const>(); + test_member_function_pointer<void (Class::*)(int, ...) const>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const>(); + + test_member_function_pointer<void (Class::*)(...) volatile>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); - test_member_function_pointer<void (Class::*)(...) volatile>(); - test_member_function_pointer<void (Class::*)(int, ...) volatile>(); - test_member_function_pointer<void (Class::*)(int, char, ...) volatile>(); // reference qualifiers on functions are a C++11 extension #if TEST_STD_VER >= 11 - test_member_function_pointer<void (Class::*)() &>(); - test_member_function_pointer<void (Class::*)(int) &>(); - test_member_function_pointer<void (Class::*)(int, char) &>(); - test_member_function_pointer<void (Class::*)(...) &>(); - test_member_function_pointer<void (Class::*)(int,...) &>(); - test_member_function_pointer<void (Class::*)(int, char,...) &>(); - - test_member_function_pointer<void (Class::*)() const &>(); - test_member_function_pointer<void (Class::*)(int) const &>(); - test_member_function_pointer<void (Class::*)(int, char) const &>(); - test_member_function_pointer<void (Class::*)(...) const &>(); - test_member_function_pointer<void (Class::*)(int,...) const &>(); - test_member_function_pointer<void (Class::*)(int, char,...) const &>(); - - test_member_function_pointer<void (Class::*)() volatile &>(); - test_member_function_pointer<void (Class::*)(int) volatile &>(); - test_member_function_pointer<void (Class::*)(int, char) volatile &>(); - test_member_function_pointer<void (Class::*)(...) volatile &>(); - test_member_function_pointer<void (Class::*)(int,...) volatile &>(); - test_member_function_pointer<void (Class::*)(int, char,...) volatile &>(); - - test_member_function_pointer<void (Class::*)() const volatile &>(); - test_member_function_pointer<void (Class::*)(int) const volatile &>(); - test_member_function_pointer<void (Class::*)(int, char) const volatile &>(); - test_member_function_pointer<void (Class::*)(...) const volatile &>(); - test_member_function_pointer<void (Class::*)(int,...) const volatile &>(); - test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>(); - - // RValue qualifiers - test_member_function_pointer<void (Class::*)() &&>(); - test_member_function_pointer<void (Class::*)(int) &&>(); - test_member_function_pointer<void (Class::*)(int, char) &&>(); - test_member_function_pointer<void (Class::*)(...) &&>(); - test_member_function_pointer<void (Class::*)(int,...) &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) &&>(); - - test_member_function_pointer<void (Class::*)() const &&>(); - test_member_function_pointer<void (Class::*)(int) const &&>(); - test_member_function_pointer<void (Class::*)(int, char) const &&>(); - test_member_function_pointer<void (Class::*)(...) const &&>(); - test_member_function_pointer<void (Class::*)(int,...) const &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) const &&>(); - - test_member_function_pointer<void (Class::*)() volatile &&>(); - test_member_function_pointer<void (Class::*)(int) volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char) volatile &&>(); - test_member_function_pointer<void (Class::*)(...) volatile &&>(); - test_member_function_pointer<void (Class::*)(int,...) volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>(); - - test_member_function_pointer<void (Class::*)() const volatile &&>(); - test_member_function_pointer<void (Class::*)(int) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char) const volatile &&>(); - test_member_function_pointer<void (Class::*)(...) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int,...) const volatile &&>(); - test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>(); + // Noexcept qualifiers + test_member_function_pointer<void (Class::*)() noexcept>(); + test_member_function_pointer<void (Class::*)(int) noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) noexcept>(); + + test_member_function_pointer<void (Class::*)() const noexcept>(); + test_member_function_pointer<void (Class::*)(int) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile noexcept>(); + + test_member_function_pointer<void (Class::*)(...) noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) noexcept>(); + + test_member_function_pointer<void (Class::*)(...) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) const noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) const noexcept>(); + + test_member_function_pointer<void (Class::*)(...) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, ...) volatile noexcept>(); + test_member_function_pointer<void (Class::*)(int, char, ...) volatile noexcept>(); + + // lvalue qualifiers + test_member_function_pointer<void (Class::*)() &>(); + test_member_function_pointer<void (Class::*)(int) &>(); + test_member_function_pointer<void (Class::*)(int, char) &>(); + test_member_function_pointer<void (Class::*)(...) &>(); + test_member_function_pointer<void (Class::*)(int,...) &>(); + test_member_function_pointer<void (Class::*)(int, char,...) &>(); + + test_member_function_pointer<void (Class::*)() const &>(); + test_member_function_pointer<void (Class::*)(int) const &>(); + test_member_function_pointer<void (Class::*)(int, char) const &>(); + test_member_function_pointer<void (Class::*)(...) const &>(); + test_member_function_pointer<void (Class::*)(int,...) const &>(); + test_member_function_pointer<void (Class::*)(int, char,...) const &>(); + + test_member_function_pointer<void (Class::*)() volatile &>(); + test_member_function_pointer<void (Class::*)(int) volatile &>(); + test_member_function_pointer<void (Class::*)(int, char) volatile &>(); + test_member_function_pointer<void (Class::*)(...) volatile &>(); + test_member_function_pointer<void (Class::*)(int,...) volatile &>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile &>(); + + test_member_function_pointer<void (Class::*)() const volatile &>(); + test_member_function_pointer<void (Class::*)(int) const volatile &>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile &>(); + test_member_function_pointer<void (Class::*)(...) const volatile &>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile &>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>(); + + // Lvalue qualifiers with noexcept + test_member_function_pointer<void (Class::*)() & noexcept>(); + test_member_function_pointer<void (Class::*)(int) & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) & noexcept>(); + test_member_function_pointer<void (Class::*)(...) & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) & noexcept>(); + + test_member_function_pointer<void (Class::*)() const & noexcept>(); + test_member_function_pointer<void (Class::*)(int) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const & noexcept>(); + test_member_function_pointer<void (Class::*)(...) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const & noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(...) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile & noexcept>(); + + test_member_function_pointer<void (Class::*)() const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(...) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile & noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile & noexcept>(); + + // RValue qualifiers + test_member_function_pointer<void (Class::*)() &&>(); + test_member_function_pointer<void (Class::*)(int) &&>(); + test_member_function_pointer<void (Class::*)(int, char) &&>(); + test_member_function_pointer<void (Class::*)(...) &&>(); + test_member_function_pointer<void (Class::*)(int,...) &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) &&>(); + + test_member_function_pointer<void (Class::*)() const &&>(); + test_member_function_pointer<void (Class::*)(int) const &&>(); + test_member_function_pointer<void (Class::*)(int, char) const &&>(); + test_member_function_pointer<void (Class::*)(...) const &&>(); + test_member_function_pointer<void (Class::*)(int,...) const &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) const &&>(); + + test_member_function_pointer<void (Class::*)() volatile &&>(); + test_member_function_pointer<void (Class::*)(int) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char) volatile &&>(); + test_member_function_pointer<void (Class::*)(...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int,...) volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>(); + + test_member_function_pointer<void (Class::*)() const volatile &&>(); + test_member_function_pointer<void (Class::*)(int) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile &&>(); + test_member_function_pointer<void (Class::*)(...) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile &&>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>(); + + // RValue qualifiers with noexcept + test_member_function_pointer<void (Class::*)() && noexcept>(); + test_member_function_pointer<void (Class::*)(int) && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) && noexcept>(); + test_member_function_pointer<void (Class::*)(...) && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) && noexcept>(); + + test_member_function_pointer<void (Class::*)() const && noexcept>(); + test_member_function_pointer<void (Class::*)(int) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const && noexcept>(); + test_member_function_pointer<void (Class::*)(...) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const && noexcept>(); + + test_member_function_pointer<void (Class::*)() volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(...) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) volatile && noexcept>(); + + test_member_function_pointer<void (Class::*)() const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(...) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int,...) const volatile && noexcept>(); + test_member_function_pointer<void (Class::*)(int, char,...) const volatile && noexcept>(); #endif // LWG#2582 - static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); + static_assert(!std::is_member_function_pointer<incomplete_type>::value, ""); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp index a54adf10258f2..99ca74cc2fa91 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp @@ -65,6 +65,14 @@ class Abstract virtual ~Abstract() = 0; }; +template <class> +struct AbstractTemplate { + virtual void test() = 0; +}; + +template <> +struct AbstractTemplate<double> {}; + int main() { test_is_not_abstract<void>(); @@ -81,4 +89,6 @@ int main() test_is_not_abstract<NotEmpty>(); test_is_abstract<Abstract>(); + test_is_abstract<AbstractTemplate<int> >(); + test_is_not_abstract<AbstractTemplate<double> >(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp new file mode 100644 index 0000000000000..9c72d4d44ce5d --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 + +// <type_traits> + +// template <class T> struct is_aggregate; +// template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value; + +#include <type_traits> +#include "test_macros.h" + +template <class T> +void test_true() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert( std::is_aggregate<T>::value, ""); + static_assert( std::is_aggregate<const T>::value, ""); + static_assert( std::is_aggregate<volatile T>::value, ""); + static_assert( std::is_aggregate<const volatile T>::value, ""); + static_assert( std::is_aggregate_v<T>, ""); + static_assert( std::is_aggregate_v<const T>, ""); + static_assert( std::is_aggregate_v<volatile T>, ""); + static_assert( std::is_aggregate_v<const volatile T>, ""); +#endif +} + +template <class T> +void test_false() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert(!std::is_aggregate<T>::value, ""); + static_assert(!std::is_aggregate<const T>::value, ""); + static_assert(!std::is_aggregate<volatile T>::value, ""); + static_assert(!std::is_aggregate<const volatile T>::value, ""); + static_assert(!std::is_aggregate_v<T>, ""); + static_assert(!std::is_aggregate_v<const T>, ""); + static_assert(!std::is_aggregate_v<volatile T>, ""); + static_assert(!std::is_aggregate_v<const volatile T>, ""); +#endif +} + +struct Aggregate {}; +struct HasCons { HasCons(int); }; +struct HasPriv { + void PreventUnusedPrivateMemberWarning(); +private: + int x; +}; +struct Union { int x; void* y; }; + + +int main () +{ + { + test_false<void>(); + test_false<int>(); + test_false<void*>(); + test_false<void()>(); + test_false<void() const>(); + test_false<void(Aggregate::*)(int) const>(); + test_false<Aggregate&>(); + test_false<HasCons>(); + test_false<HasPriv>(); + } + { + test_true<Aggregate>(); + test_true<Aggregate[]>(); + test_true<Aggregate[42][101]>(); + test_true<Union>(); + } +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp index f4736e7134226..3955d4bc3306b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -82,5 +82,4 @@ int main() // pointer to incomplete template type test_is_assignable<X<D>*&, X<D>*> (); - test_is_not_assignable<Incomplete&, Incomplete const&>(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp index f6ae401533a98..9d2ec5edea583 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp @@ -251,6 +251,7 @@ int main() LIBCPP_STATIC_ASSERT( clang_disallows_valid_static_cast_bug != std::__libcpp_is_constructible<int&&, ExplicitTo<int&&>>::value, ""); + ((void)clang_disallows_valid_static_cast_bug); // Prevent unused warning #else static_assert(clang_disallows_valid_static_cast_bug == false, ""); LIBCPP_STATIC_ASSERT(std::__libcpp_is_constructible<int&&, ExplicitTo<int&&>>::value, ""); diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp index 59aa5e26a2921..7ead5f5d5df95 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp @@ -77,7 +77,7 @@ int main() #endif // Before C++14, void was not a literal type -// In C++14, cv-void is is a literal type +// In C++14, cv-void is a literal type #if TEST_STD_VER < 14 test_is_not_literal_type<void>(); #else diff --git a/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp index b54a08f5575ba..29fb7a8431f1a 100644 --- a/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp @@ -17,37 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator == ( const X &lhs, const X &rhs ) - { return lhs.i_ == rhs.i_ ; } +constexpr bool operator==(const X& lhs, const X& rhs) { + return lhs.i_ == rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 == T(1)), "" ); - static_assert ( (o2 == T(1)), "" ); - static_assert ( !(o3 == T(1)), "" ); - static_assert ( (o3 == T(2)), "" ); - static_assert ( (o3 == val), "" ); - - static_assert ( !(T(1) == o1), "" ); - static_assert ( (T(1) == o2), "" ); - static_assert ( !(T(1) == o3), "" ); - static_assert ( (T(2) == o3), "" ); - static_assert ( (val == o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 == T(1)), ""); + static_assert((o2 == T(1)), ""); + static_assert(!(o3 == T(1)), ""); + static_assert((o3 == T(2)), ""); + static_assert((o3 == val), ""); + + static_assert(!(T(1) == o1), ""); + static_assert((T(1) == o2), ""); + static_assert(!(T(1) == o3), ""); + static_assert((T(2) == o3), ""); + static_assert((val == o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 == 42l, ""); + static_assert(!(101l == o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 == 42, ""); + static_assert(!(101 == o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp index 064114fb9db2b..ae34eb20517e7 100644 --- a/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp @@ -17,39 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator > ( const X &lhs, const X &rhs ) - { return lhs.i_ > rhs.i_ ; } +constexpr bool operator>(const X& lhs, const X& rhs) { return lhs.i_ > rhs.i_; } -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 > T(1)), "" ); - static_assert ( !(o2 > T(1)), "" ); // equal - static_assert ( (o3 > T(1)), "" ); - static_assert ( !(o2 > val), "" ); - static_assert ( !(o3 > val), "" ); // equal - static_assert ( !(o3 > T(3)), "" ); - - static_assert ( (T(1) > o1), "" ); - static_assert ( !(T(1) > o2), "" ); // equal - static_assert ( !(T(1) > o3), "" ); - static_assert ( (val > o2), "" ); - static_assert ( !(val > o3), "" ); // equal - static_assert ( (T(3) > o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 > T(1)), ""); + static_assert(!(o2 > T(1)), ""); // equal + static_assert((o3 > T(1)), ""); + static_assert(!(o2 > val), ""); + static_assert(!(o3 > val), ""); // equal + static_assert(!(o3 > T(3)), ""); + + static_assert((T(1) > o1), ""); + static_assert(!(T(1) > o2), ""); // equal + static_assert(!(T(1) > o3), ""); + static_assert((val > o2), ""); + static_assert(!(val > o3), ""); // equal + static_assert((T(3) > o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 > 11l, ""); + static_assert(!(42l > o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 > 11, ""); + static_assert(!(42 > o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp index 663686cdf3478..dac94002661f8 100644 --- a/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp @@ -17,39 +17,50 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator >= ( const X &lhs, const X &rhs ) - { return lhs.i_ >= rhs.i_ ; } +constexpr bool operator>=(const X& lhs, const X& rhs) { + return lhs.i_ >= rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( !(o1 >= T(1)), "" ); - static_assert ( (o2 >= T(1)), "" ); // equal - static_assert ( (o3 >= T(1)), "" ); - static_assert ( !(o2 >= val), "" ); - static_assert ( (o3 >= val), "" ); // equal - static_assert ( !(o3 >= T(3)), "" ); - - static_assert ( (T(1) >= o1), "" ); - static_assert ( (T(1) >= o2), "" ); // equal - static_assert ( !(T(1) >= o3), "" ); - static_assert ( (val >= o2), "" ); - static_assert ( (val >= o3), "" ); // equal - static_assert ( (T(3) >= o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert(!(o1 >= T(1)), ""); + static_assert((o2 >= T(1)), ""); // equal + static_assert((o3 >= T(1)), ""); + static_assert(!(o2 >= val), ""); + static_assert((o3 >= val), ""); // equal + static_assert(!(o3 >= T(3)), ""); + + static_assert((T(1) >= o1), ""); + static_assert((T(1) >= o2), ""); // equal + static_assert(!(T(1) >= o3), ""); + static_assert((val >= o2), ""); + static_assert((val >= o3), ""); // equal + static_assert((T(3) >= o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 >= 42l, ""); + static_assert(!(11l >= o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 >= 42, ""); + static_assert(!(11 >= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp index 05ac5eb12b48a..b71f8363b0a62 100644 --- a/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp @@ -17,39 +17,50 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator <= ( const X &lhs, const X &rhs ) - { return lhs.i_ <= rhs.i_ ; } +constexpr bool operator<=(const X& lhs, const X& rhs) { + return lhs.i_ <= rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 <= T(1)), "" ); - static_assert ( (o2 <= T(1)), "" ); // equal - static_assert ( !(o3 <= T(1)), "" ); - static_assert ( (o2 <= val), "" ); - static_assert ( (o3 <= val), "" ); // equal - static_assert ( (o3 <= T(3)), "" ); - - static_assert ( !(T(1) <= o1), "" ); - static_assert ( (T(1) <= o2), "" ); // equal - static_assert ( (T(1) <= o3), "" ); - static_assert ( !(val <= o2), "" ); - static_assert ( (val <= o3), "" ); // equal - static_assert ( !(T(3) <= o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 <= T(1)), ""); + static_assert((o2 <= T(1)), ""); // equal + static_assert(!(o3 <= T(1)), ""); + static_assert((o2 <= val), ""); + static_assert((o3 <= val), ""); // equal + static_assert((o3 <= T(3)), ""); + + static_assert(!(T(1) <= o1), ""); + static_assert((T(1) <= o2), ""); // equal + static_assert((T(1) <= o3), ""); + static_assert(!(val <= o2), ""); + static_assert((val <= o3), ""); // equal + static_assert(!(T(3) <= o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 <= 42l, ""); + static_assert(!(101l <= o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 <= 42, ""); + static_assert(!(101 <= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp index d1891a286d7b8..84456b3baa6ef 100644 --- a/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp @@ -17,39 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator < ( const X &lhs, const X &rhs ) - { return lhs.i_ < rhs.i_ ; } +constexpr bool operator<(const X& lhs, const X& rhs) { return lhs.i_ < rhs.i_; } -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 < T(1)), "" ); - static_assert ( !(o2 < T(1)), "" ); // equal - static_assert ( !(o3 < T(1)), "" ); - static_assert ( (o2 < val), "" ); - static_assert ( !(o3 < val), "" ); // equal - static_assert ( (o3 < T(3)), "" ); - - static_assert ( !(T(1) < o1), "" ); - static_assert ( !(T(1) < o2), "" ); // equal - static_assert ( (T(1) < o3), "" ); - static_assert ( !(val < o2), "" ); - static_assert ( !(val < o3), "" ); // equal - static_assert ( !(T(3) < o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 < T(1)), ""); + static_assert(!(o2 < T(1)), ""); // equal + static_assert(!(o3 < T(1)), ""); + static_assert((o2 < val), ""); + static_assert(!(o3 < val), ""); // equal + static_assert((o3 < T(3)), ""); + + static_assert(!(T(1) < o1), ""); + static_assert(!(T(1) < o2), ""); // equal + static_assert((T(1) < o3), ""); + static_assert(!(val < o2), ""); + static_assert(!(val < o3), ""); // equal + static_assert(!(T(3) < o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 < 101l, ""); + static_assert(!(42l < o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 < 101, ""); + static_assert(!(42 < o1), ""); + } } diff --git a/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp b/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp index ae2ff808fb25a..a4ffdc25e7213 100644 --- a/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp +++ b/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp @@ -17,37 +17,48 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator != ( const X &lhs, const X &rhs ) - { return lhs.i_ != rhs.i_ ; } +constexpr bool operator!=(const X& lhs, const X& rhs) { + return lhs.i_ != rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; constexpr T val(2); - constexpr O o1; // disengaged - constexpr O o2{1}; // engaged - constexpr O o3{val}; // engaged - - static_assert ( (o1 != T(1)), "" ); - static_assert ( !(o2 != T(1)), "" ); - static_assert ( (o3 != T(1)), "" ); - static_assert ( !(o3 != T(2)), "" ); - static_assert ( !(o3 != val), "" ); - - static_assert ( (T(1) != o1), "" ); - static_assert ( !(T(1) != o2), "" ); - static_assert ( (T(1) != o3), "" ); - static_assert ( !(T(2) != o3), "" ); - static_assert ( !(val != o3), "" ); - } + constexpr O o1; // disengaged + constexpr O o2{1}; // engaged + constexpr O o3{val}; // engaged + + static_assert((o1 != T(1)), ""); + static_assert(!(o2 != T(1)), ""); + static_assert((o3 != T(1)), ""); + static_assert(!(o3 != T(2)), ""); + static_assert(!(o3 != val), ""); + + static_assert((T(1) != o1), ""); + static_assert(!(T(1) != o2), ""); + static_assert((T(1) != o3), ""); + static_assert(!(T(2) != o3), ""); + static_assert(!(val != o3), ""); + } + { + using O = optional<int>; + constexpr O o1(42); + static_assert(o1 != 101l, ""); + static_assert(!(42l != o1), ""); + } + { + using O = optional<const int>; + constexpr O o1(42); + static_assert(o1 != 101, ""); + static_assert(!(42 != o1), ""); + } } diff --git a/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp b/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp new file mode 100644 index 0000000000000..e54a4ced84118 --- /dev/null +++ b/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 + +// <optional> + +// Test that <optional> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <optional> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + + } +} diff --git a/test/std/utilities/optional/optional.hash/hash.pass.cpp b/test/std/utilities/optional/optional.hash/hash.pass.cpp index dfdd07ddf452e..8c91d6da761e2 100644 --- a/test/std/utilities/optional/optional.hash/hash.pass.cpp +++ b/test/std/utilities/optional/optional.hash/hash.pass.cpp @@ -17,6 +17,19 @@ #include <memory> #include <cassert> +#include "poisoned_hash_helper.hpp" + +struct A {}; +struct B {}; + +namespace std { + +template <> +struct hash<B> { + size_t operator()(B const&) noexcept(false) { return 0; } +}; + +} int main() { @@ -27,6 +40,7 @@ int main() { typedef int T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = 2; assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -34,6 +48,7 @@ int main() { typedef std::string T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::string("123"); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -41,8 +56,21 @@ int main() { typedef std::unique_ptr<int> T; optional<T> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::unique_ptr<int>(new int(3)); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); } + { + test_hash_enabled_for_type<std::optional<int> >(); + test_hash_enabled_for_type<std::optional<int*> >(); + test_hash_enabled_for_type<std::optional<const int> >(); + test_hash_enabled_for_type<std::optional<int* const> >(); + + test_hash_disabled_for_type<std::optional<A>>(); + test_hash_disabled_for_type<std::optional<const A>>(); + + test_hash_enabled_for_type<std::optional<B>>(); + test_hash_enabled_for_type<std::optional<const B>>(); + } } diff --git a/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp b/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp new file mode 100644 index 0000000000000..f9ea7b47911fa --- /dev/null +++ b/test/std/utilities/optional/optional.nullopt/nullopt_t.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 +// <optional> + +// struct nullopt_t{see below}; +// constexpr nullopt_t nullopt(unspecified); + +// [optional.nullopt]/2: +// Type nullopt_t shall not have a default constructor or an initializer-list constructor. +// It shall not be an aggregate and shall be a literal type. +// Constant nullopt shall be initialized with an argument of literal type. + +#include <optional> +#include "test_macros.h" + +int main() +{ + std::nullopt_t n = {}; +} diff --git a/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp b/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp index 84bb29fabac8d..9b752a665a837 100644 --- a/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp +++ b/test/std/utilities/optional/optional.nullopt/nullopt_t.pass.cpp @@ -13,6 +13,11 @@ // struct nullopt_t{see below}; // constexpr nullopt_t nullopt(unspecified); +// [optional.nullopt]/2: +// Type nullopt_t shall not have a default constructor or an initializer-list constructor. +// It shall not be an aggregate and shall be a literal type. +// Constant nullopt shall be initialized with an argument of literal type. + #include <optional> #include <type_traits> @@ -29,9 +34,9 @@ test(const nullopt_t&) int main() { - static_assert((std::is_class<nullopt_t>::value), ""); - static_assert((std::is_empty<nullopt_t>::value), ""); - static_assert((std::is_literal_type<nullopt_t>::value), ""); + static_assert(( std::is_class<nullopt_t>::value), ""); + static_assert(( std::is_empty<nullopt_t>::value), ""); + static_assert(( std::is_literal_type<nullopt_t>::value), ""); static_assert((!std::is_default_constructible<nullopt_t>::value), ""); static_assert(test(nullopt) == 3, ""); diff --git a/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp index 1207e24150ff7..0fcc52be13546 100644 --- a/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp @@ -216,7 +216,6 @@ void test_throws() #ifndef TEST_HAS_NO_EXCEPTIONS using T = ThrowAssign; { - using T = ThrowAssign; optional<T> opt; try { opt = 42; diff --git a/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp index b5362589963c2..0696c11526d59 100644 --- a/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // <optional> -// template <class... Args> void optional<T>::emplace(Args&&... args); +// template <class... Args> T& optional<T>::emplace(Args&&... args); #include <optional> #include <type_traits> @@ -51,27 +51,35 @@ void test_one_arg() { using Opt = std::optional<T>; { Opt opt; - opt.emplace(); + auto & v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(0)); + assert(&v == &*opt); } { Opt opt; - opt.emplace(1); + auto & v = opt.emplace(1); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(1)); + assert(&v == &*opt); } { Opt opt(2); - opt.emplace(); + auto & v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(0)); + assert(&v == &*opt); } { Opt opt(2); - opt.emplace(1); + auto & v = opt.emplace(1); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); assert(*opt == T(1)); + assert(&v == &*opt); } } @@ -83,20 +91,26 @@ void test_multi_arg() using Opt = std::optional<T>; { Opt opt; - opt.emplace(101, 41); + auto &v = opt.emplace(101, 41); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); + assert( v == T(101, 41)); assert(*opt == T(101, 41)); } { Opt opt; - opt.emplace({1, 2, 3, 4}); + auto &v = opt.emplace({1, 2, 3, 4}); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); - assert(*opt == T(4)); // T sets its value to the size of the init list + assert( v == T(4)); // T sets its value to the size of the init list + assert(*opt == T(4)); } { Opt opt; - opt.emplace({1, 2, 3, 4, 5}, 6); + auto &v = opt.emplace({1, 2, 3, 4, 5}, 6); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(static_cast<bool>(opt) == true); + assert( v == T(5)); // T sets its value to the size of the init list assert(*opt == T(5)); // T sets its value to the size of the init list } } @@ -109,73 +123,87 @@ void test_on_test_type() { assert(T::alive == 0); { T::reset_constructors(); - opt.emplace(); + auto &v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::default_constructed == 1); assert(T::destroyed == 0); assert(static_cast<bool>(opt) == true); assert(*opt == T()); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(); + auto &v = opt.emplace(); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::default_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T()); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(101); + auto &v = opt.emplace(101); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(101)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(-10, 99); + auto &v = opt.emplace(-10, 99); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(-10, 99)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace(-10, 99); + auto &v = opt.emplace(-10, 99); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(-10, 99)); + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace({-10, 99, 42, 1}); + auto &v = opt.emplace({-10, 99, 42, 1}); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(4)); // size of the initializer list + assert(&v == &*opt); } { T::reset_constructors(); - opt.emplace({-10, 99, 42, 1}, 42); + auto &v = opt.emplace({-10, 99, 42, 1}, 42); + static_assert( std::is_same_v<T&, decltype(v)>, "" ); assert(T::alive == 1); assert(T::constructed == 1); assert(T::value_constructed == 1); assert(T::destroyed == 1); assert(static_cast<bool>(opt) == true); assert(*opt == T(4)); // size of the initializer list + assert(&v == &*opt); } } @@ -210,8 +238,10 @@ int main() } { optional<const int> opt; - opt.emplace(42); + auto &v = opt.emplace(42); + static_assert( std::is_same_v<const int&, decltype(v)>, "" ); assert(*opt == 42); + assert( v == 42); opt.emplace(); assert(*opt == 0); } diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp index c4d4763a6f0ae..d068fbc2db7e7 100644 --- a/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp @@ -35,6 +35,11 @@ struct ExplicitThrow constexpr explicit ExplicitThrow(int x) { if (x != -1) TEST_THROW(6);} }; +struct ImplicitAny { + template <class U> + constexpr ImplicitAny(U&&) {} +}; + template <class To, class From> constexpr bool implicit_conversion(optional<To>&& opt, const From& v) @@ -61,11 +66,9 @@ constexpr bool explicit_conversion(Input&& in, const Expect& v) void test_implicit() { { - using T = long long; static_assert(implicit_conversion<long long>(42, 42), ""); } { - using T = long double; static_assert(implicit_conversion<long double>(3.14, 3.14), ""); } { @@ -81,6 +84,15 @@ void test_implicit() using T = TestTypes::TestType; assert(implicit_conversion<T>(3, T(3))); } + { + using O = optional<ImplicitAny>; + static_assert(!test_convertible<O, std::in_place_t>(), ""); + static_assert(!test_convertible<O, std::in_place_t&>(), ""); + static_assert(!test_convertible<O, const std::in_place_t&>(), ""); + static_assert(!test_convertible<O, std::in_place_t&&>(), ""); + static_assert(!test_convertible<O, const std::in_place_t&&>(), ""); + + } #ifndef TEST_HAS_NO_EXCEPTIONS { try { @@ -97,18 +109,15 @@ void test_implicit() void test_explicit() { { using T = ExplicitTrivialTestTypes::TestType; - using O = optional<T>; static_assert(explicit_conversion<T>(42, 42), ""); } { using T = ExplicitConstexprTestTypes::TestType; - using O = optional<T>; static_assert(explicit_conversion<T>(42, 42), ""); static_assert(!std::is_convertible<int, T>::value, ""); } { using T = ExplicitTestTypes::TestType; - using O = optional<T>; T::reset(); { assert(explicit_conversion<T>(42, 42)); diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp new file mode 100644 index 0000000000000..d9e5ca821e85f --- /dev/null +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 +// <optional> + +// constexpr optional(const optional<T>& rhs); +// If is_trivially_copy_constructible_v<T> is true, +// this constructor shall be a constexpr constructor. + +#include <optional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct S { + constexpr S() : v_(0) {} + S(int v) : v_(v) {} + S(const S &rhs) : v_(rhs.v_) {} // make it not trivially copyable + int v_; + }; + + +int main() +{ + static_assert (!std::is_trivially_copy_constructible_v<S>, "" ); + constexpr std::optional<S> o1; + constexpr std::optional<S> o2 = o1; // not constexpr +} diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp new file mode 100644 index 0000000000000..c7458d95abfd3 --- /dev/null +++ b/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 +// <optional> + +// constexpr optional(const optional<T>&& rhs); +// If is_trivially_move_constructible_v<T> is true, +// this constructor shall be a constexpr constructor. + +#include <optional> +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +struct S { + constexpr S() : v_(0) {} + S(int v) : v_(v) {} + constexpr S(const S &rhs) : v_(rhs.v_) {} // not trivially moveable + constexpr S(const S &&rhs) : v_(rhs.v_) {} // not trivially moveable + int v_; + }; + + +int main() +{ + static_assert (!std::is_trivially_move_constructible_v<S>, "" ); + constexpr std::optional<S> o1; + constexpr std::optional<S> o2 = std::move(o1); // not constexpr +} diff --git a/test/std/utilities/optional/optional.relops/equal.pass.cpp b/test/std/utilities/optional/optional.relops/equal.pass.cpp index 6650b6720a8e9..7667540f97601 100644 --- a/test/std/utilities/optional/optional.relops/equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/equal.pass.cpp @@ -18,57 +18,69 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator == ( const X &lhs, const X &rhs ) - { return lhs.i_ == rhs.i_ ; } +constexpr bool operator==(const X& lhs, const X& rhs) { + return lhs.i_ == rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged - - static_assert ( o1 == o1 , "" ); - static_assert ( o1 == o2 , "" ); - static_assert ( !(o1 == o3), "" ); - static_assert ( !(o1 == o4), "" ); - static_assert ( !(o1 == o5), "" ); + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( o2 == o1 , "" ); - static_assert ( o2 == o2 , "" ); - static_assert ( !(o2 == o3), "" ); - static_assert ( !(o2 == o4), "" ); - static_assert ( !(o2 == o5), "" ); + static_assert(o1 == o1, ""); + static_assert(o1 == o2, ""); + static_assert(!(o1 == o3), ""); + static_assert(!(o1 == o4), ""); + static_assert(!(o1 == o5), ""); - static_assert ( !(o3 == o1), "" ); - static_assert ( !(o3 == o2), "" ); - static_assert ( o3 == o3 , "" ); - static_assert ( !(o3 == o4), "" ); - static_assert ( o3 == o5 , "" ); + static_assert(o2 == o1, ""); + static_assert(o2 == o2, ""); + static_assert(!(o2 == o3), ""); + static_assert(!(o2 == o4), ""); + static_assert(!(o2 == o5), ""); - static_assert ( !(o4 == o1), "" ); - static_assert ( !(o4 == o2), "" ); - static_assert ( !(o4 == o3), "" ); - static_assert ( o4 == o4 , "" ); - static_assert ( !(o4 == o5), "" ); + static_assert(!(o3 == o1), ""); + static_assert(!(o3 == o2), ""); + static_assert(o3 == o3, ""); + static_assert(!(o3 == o4), ""); + static_assert(o3 == o5, ""); - static_assert ( !(o5 == o1), "" ); - static_assert ( !(o5 == o2), "" ); - static_assert ( o5 == o3 , "" ); - static_assert ( !(o5 == o4), "" ); - static_assert ( o5 == o5 , "" ); + static_assert(!(o4 == o1), ""); + static_assert(!(o4 == o2), ""); + static_assert(!(o4 == o3), ""); + static_assert(o4 == o4, ""); + static_assert(!(o4 == o5), ""); - } + static_assert(!(o5 == o1), ""); + static_assert(!(o5 == o2), ""); + static_assert(o5 == o3, ""); + static_assert(!(o5 == o4), ""); + static_assert(o5 == o5, ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 == O2(42), ""); + static_assert(!(O2(101) == o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 == O2(42), ""); + static_assert(!(O2(101) == o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp b/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp index f9b30449638aa..0e05834c147a5 100644 --- a/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp @@ -16,55 +16,68 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator >= ( const X &lhs, const X &rhs ) - { return lhs.i_ >= rhs.i_ ; } +constexpr bool operator>=(const X& lhs, const X& rhs) { + return lhs.i_ >= rhs.i_; +} -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( (o1 >= o1), "" ); - static_assert ( (o1 >= o2), "" ); - static_assert ( !(o1 >= o3), "" ); - static_assert ( !(o1 >= o4), "" ); - static_assert ( !(o1 >= o5), "" ); + static_assert((o1 >= o1), ""); + static_assert((o1 >= o2), ""); + static_assert(!(o1 >= o3), ""); + static_assert(!(o1 >= o4), ""); + static_assert(!(o1 >= o5), ""); - static_assert ( (o2 >= o1), "" ); - static_assert ( (o2 >= o2), "" ); - static_assert ( !(o2 >= o3), "" ); - static_assert ( !(o2 >= o4), "" ); - static_assert ( !(o2 >= o5), "" ); + static_assert((o2 >= o1), ""); + static_assert((o2 >= o2), ""); + static_assert(!(o2 >= o3), ""); + static_assert(!(o2 >= o4), ""); + static_assert(!(o2 >= o5), ""); - static_assert ( (o3 >= o1), "" ); - static_assert ( (o3 >= o2), "" ); - static_assert ( (o3 >= o3), "" ); - static_assert ( !(o3 >= o4), "" ); - static_assert ( (o3 >= o5), "" ); + static_assert((o3 >= o1), ""); + static_assert((o3 >= o2), ""); + static_assert((o3 >= o3), ""); + static_assert(!(o3 >= o4), ""); + static_assert((o3 >= o5), ""); - static_assert ( (o4 >= o1), "" ); - static_assert ( (o4 >= o2), "" ); - static_assert ( (o4 >= o3), "" ); - static_assert ( (o4 >= o4), "" ); - static_assert ( (o4 >= o5), "" ); + static_assert((o4 >= o1), ""); + static_assert((o4 >= o2), ""); + static_assert((o4 >= o3), ""); + static_assert((o4 >= o4), ""); + static_assert((o4 >= o5), ""); - static_assert ( (o5 >= o1), "" ); - static_assert ( (o5 >= o2), "" ); - static_assert ( (o5 >= o3), "" ); - static_assert ( !(o5 >= o4), "" ); - static_assert ( (o5 >= o5), "" ); - } + static_assert((o5 >= o1), ""); + static_assert((o5 >= o2), ""); + static_assert((o5 >= o3), ""); + static_assert(!(o5 >= o4), ""); + static_assert((o5 >= o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 >= O2(42), ""); + static_assert(!(O2(11) >= o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 >= O2(42), ""); + static_assert(!(O2(1) >= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/greater_than.pass.cpp b/test/std/utilities/optional/optional.relops/greater_than.pass.cpp index 8a27eb471f283..3946a6102ba9d 100644 --- a/test/std/utilities/optional/optional.relops/greater_than.pass.cpp +++ b/test/std/utilities/optional/optional.relops/greater_than.pass.cpp @@ -16,55 +16,66 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator > ( const X &lhs, const X &rhs ) - { return lhs.i_ > rhs.i_ ; } +constexpr bool operator>(const X& lhs, const X& rhs) { return lhs.i_ > rhs.i_; } -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o1 > o1), "" ); - static_assert ( !(o1 > o2), "" ); - static_assert ( !(o1 > o3), "" ); - static_assert ( !(o1 > o4), "" ); - static_assert ( !(o1 > o5), "" ); + static_assert(!(o1 > o1), ""); + static_assert(!(o1 > o2), ""); + static_assert(!(o1 > o3), ""); + static_assert(!(o1 > o4), ""); + static_assert(!(o1 > o5), ""); - static_assert ( !(o2 > o1), "" ); - static_assert ( !(o2 > o2), "" ); - static_assert ( !(o2 > o3), "" ); - static_assert ( !(o2 > o4), "" ); - static_assert ( !(o2 > o5), "" ); + static_assert(!(o2 > o1), ""); + static_assert(!(o2 > o2), ""); + static_assert(!(o2 > o3), ""); + static_assert(!(o2 > o4), ""); + static_assert(!(o2 > o5), ""); - static_assert ( (o3 > o1), "" ); - static_assert ( (o3 > o2), "" ); - static_assert ( !(o3 > o3), "" ); - static_assert ( !(o3 > o4), "" ); - static_assert ( !(o3 > o5), "" ); + static_assert((o3 > o1), ""); + static_assert((o3 > o2), ""); + static_assert(!(o3 > o3), ""); + static_assert(!(o3 > o4), ""); + static_assert(!(o3 > o5), ""); - static_assert ( (o4 > o1), "" ); - static_assert ( (o4 > o2), "" ); - static_assert ( (o4 > o3), "" ); - static_assert ( !(o4 > o4), "" ); - static_assert ( (o4 > o5), "" ); + static_assert((o4 > o1), ""); + static_assert((o4 > o2), ""); + static_assert((o4 > o3), ""); + static_assert(!(o4 > o4), ""); + static_assert((o4 > o5), ""); - static_assert ( (o5 > o1), "" ); - static_assert ( (o5 > o2), "" ); - static_assert ( !(o5 > o3), "" ); - static_assert ( !(o5 > o4), "" ); - static_assert ( !(o5 > o5), "" ); - } + static_assert((o5 > o1), ""); + static_assert((o5 > o2), ""); + static_assert(!(o5 > o3), ""); + static_assert(!(o5 > o4), ""); + static_assert(!(o5 > o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 > O2(1), ""); + static_assert(!(O2(42) > o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 > O2(1), ""); + static_assert(!(O2(42) > o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/less_equal.pass.cpp b/test/std/utilities/optional/optional.relops/less_equal.pass.cpp index a7d594dd34a2d..5a1954154f442 100644 --- a/test/std/utilities/optional/optional.relops/less_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/less_equal.pass.cpp @@ -16,55 +16,68 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator <= ( const X &lhs, const X &rhs ) - { return lhs.i_ <= rhs.i_ ; } +constexpr bool operator<=(const X& lhs, const X& rhs) { + return lhs.i_ <= rhs.i_; +} -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( (o1 <= o1), "" ); - static_assert ( (o1 <= o2), "" ); - static_assert ( (o1 <= o3), "" ); - static_assert ( (o1 <= o4), "" ); - static_assert ( (o1 <= o5), "" ); + static_assert((o1 <= o1), ""); + static_assert((o1 <= o2), ""); + static_assert((o1 <= o3), ""); + static_assert((o1 <= o4), ""); + static_assert((o1 <= o5), ""); - static_assert ( (o2 <= o1), "" ); - static_assert ( (o2 <= o2), "" ); - static_assert ( (o2 <= o3), "" ); - static_assert ( (o2 <= o4), "" ); - static_assert ( (o2 <= o5), "" ); + static_assert((o2 <= o1), ""); + static_assert((o2 <= o2), ""); + static_assert((o2 <= o3), ""); + static_assert((o2 <= o4), ""); + static_assert((o2 <= o5), ""); - static_assert ( !(o3 <= o1), "" ); - static_assert ( !(o3 <= o2), "" ); - static_assert ( (o3 <= o3), "" ); - static_assert ( (o3 <= o4), "" ); - static_assert ( (o3 <= o5), "" ); + static_assert(!(o3 <= o1), ""); + static_assert(!(o3 <= o2), ""); + static_assert((o3 <= o3), ""); + static_assert((o3 <= o4), ""); + static_assert((o3 <= o5), ""); - static_assert ( !(o4 <= o1), "" ); - static_assert ( !(o4 <= o2), "" ); - static_assert ( !(o4 <= o3), "" ); - static_assert ( (o4 <= o4), "" ); - static_assert ( !(o4 <= o5), "" ); + static_assert(!(o4 <= o1), ""); + static_assert(!(o4 <= o2), ""); + static_assert(!(o4 <= o3), ""); + static_assert((o4 <= o4), ""); + static_assert(!(o4 <= o5), ""); - static_assert ( !(o5 <= o1), "" ); - static_assert ( !(o5 <= o2), "" ); - static_assert ( (o5 <= o3), "" ); - static_assert ( (o5 <= o4), "" ); - static_assert ( (o5 <= o5), "" ); - } + static_assert(!(o5 <= o1), ""); + static_assert(!(o5 <= o2), ""); + static_assert((o5 <= o3), ""); + static_assert((o5 <= o4), ""); + static_assert((o5 <= o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 <= O2(42), ""); + static_assert(!(O2(101) <= o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 <= O2(42), ""); + static_assert(!(O2(101) <= o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/less_than.pass.cpp b/test/std/utilities/optional/optional.relops/less_than.pass.cpp index deffa5e849f9d..35956e6f4a70e 100644 --- a/test/std/utilities/optional/optional.relops/less_than.pass.cpp +++ b/test/std/utilities/optional/optional.relops/less_than.pass.cpp @@ -16,55 +16,66 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator < ( const X &lhs, const X &rhs ) - { return lhs.i_ < rhs.i_ ; } +constexpr bool operator<(const X& lhs, const X& rhs) { return lhs.i_ < rhs.i_; } -int main() -{ - { +int main() { + { typedef optional<X> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o1 < o1), "" ); - static_assert ( !(o1 < o2), "" ); - static_assert ( (o1 < o3), "" ); - static_assert ( (o1 < o4), "" ); - static_assert ( (o1 < o5), "" ); + static_assert(!(o1 < o1), ""); + static_assert(!(o1 < o2), ""); + static_assert((o1 < o3), ""); + static_assert((o1 < o4), ""); + static_assert((o1 < o5), ""); - static_assert ( !(o2 < o1), "" ); - static_assert ( !(o2 < o2), "" ); - static_assert ( (o2 < o3), "" ); - static_assert ( (o2 < o4), "" ); - static_assert ( (o2 < o5), "" ); + static_assert(!(o2 < o1), ""); + static_assert(!(o2 < o2), ""); + static_assert((o2 < o3), ""); + static_assert((o2 < o4), ""); + static_assert((o2 < o5), ""); - static_assert ( !(o3 < o1), "" ); - static_assert ( !(o3 < o2), "" ); - static_assert ( !(o3 < o3), "" ); - static_assert ( (o3 < o4), "" ); - static_assert ( !(o3 < o5), "" ); + static_assert(!(o3 < o1), ""); + static_assert(!(o3 < o2), ""); + static_assert(!(o3 < o3), ""); + static_assert((o3 < o4), ""); + static_assert(!(o3 < o5), ""); - static_assert ( !(o4 < o1), "" ); - static_assert ( !(o4 < o2), "" ); - static_assert ( !(o4 < o3), "" ); - static_assert ( !(o4 < o4), "" ); - static_assert ( !(o4 < o5), "" ); + static_assert(!(o4 < o1), ""); + static_assert(!(o4 < o2), ""); + static_assert(!(o4 < o3), ""); + static_assert(!(o4 < o4), ""); + static_assert(!(o4 < o5), ""); - static_assert ( !(o5 < o1), "" ); - static_assert ( !(o5 < o2), "" ); - static_assert ( !(o5 < o3), "" ); - static_assert ( (o5 < o4), "" ); - static_assert ( !(o5 < o5), "" ); - } + static_assert(!(o5 < o1), ""); + static_assert(!(o5 < o2), ""); + static_assert(!(o5 < o3), ""); + static_assert((o5 < o4), ""); + static_assert(!(o5 < o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 < O2(101), ""); + static_assert(!(O2(101) < o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 < O2(101), ""); + static_assert(!(O2(101) < o1), ""); + } } diff --git a/test/std/utilities/optional/optional.relops/not_equal.pass.cpp b/test/std/utilities/optional/optional.relops/not_equal.pass.cpp index fd11b2a207ca8..1256537d6a867 100644 --- a/test/std/utilities/optional/optional.relops/not_equal.pass.cpp +++ b/test/std/utilities/optional/optional.relops/not_equal.pass.cpp @@ -18,57 +18,69 @@ using std::optional; -struct X -{ - int i_; +struct X { + int i_; - constexpr X(int i) : i_(i) {} + constexpr X(int i) : i_(i) {} }; -constexpr bool operator != ( const X &lhs, const X &rhs ) - { return lhs.i_ != rhs.i_ ; } +constexpr bool operator!=(const X& lhs, const X& rhs) { + return lhs.i_ != rhs.i_; +} -int main() -{ - { +int main() { + { typedef X T; typedef optional<T> O; - constexpr O o1; // disengaged - constexpr O o2; // disengaged - constexpr O o3{1}; // engaged - constexpr O o4{2}; // engaged - constexpr O o5{1}; // engaged - - static_assert ( !(o1 != o1), "" ); - static_assert ( !(o1 != o2), "" ); - static_assert ( (o1 != o3), "" ); - static_assert ( (o1 != o4), "" ); - static_assert ( (o1 != o5), "" ); + constexpr O o1; // disengaged + constexpr O o2; // disengaged + constexpr O o3{1}; // engaged + constexpr O o4{2}; // engaged + constexpr O o5{1}; // engaged - static_assert ( !(o2 != o1), "" ); - static_assert ( !(o2 != o2), "" ); - static_assert ( (o2 != o3), "" ); - static_assert ( (o2 != o4), "" ); - static_assert ( (o2 != o5), "" ); + static_assert(!(o1 != o1), ""); + static_assert(!(o1 != o2), ""); + static_assert((o1 != o3), ""); + static_assert((o1 != o4), ""); + static_assert((o1 != o5), ""); - static_assert ( (o3 != o1), "" ); - static_assert ( (o3 != o2), "" ); - static_assert ( !(o3 != o3), "" ); - static_assert ( (o3 != o4), "" ); - static_assert ( !(o3 != o5), "" ); + static_assert(!(o2 != o1), ""); + static_assert(!(o2 != o2), ""); + static_assert((o2 != o3), ""); + static_assert((o2 != o4), ""); + static_assert((o2 != o5), ""); - static_assert ( (o4 != o1), "" ); - static_assert ( (o4 != o2), "" ); - static_assert ( (o4 != o3), "" ); - static_assert ( !(o4 != o4), "" ); - static_assert ( (o4 != o5), "" ); + static_assert((o3 != o1), ""); + static_assert((o3 != o2), ""); + static_assert(!(o3 != o3), ""); + static_assert((o3 != o4), ""); + static_assert(!(o3 != o5), ""); - static_assert ( (o5 != o1), "" ); - static_assert ( (o5 != o2), "" ); - static_assert ( !(o5 != o3), "" ); - static_assert ( (o5 != o4), "" ); - static_assert ( !(o5 != o5), "" ); + static_assert((o4 != o1), ""); + static_assert((o4 != o2), ""); + static_assert((o4 != o3), ""); + static_assert(!(o4 != o4), ""); + static_assert((o4 != o5), ""); - } + static_assert((o5 != o1), ""); + static_assert((o5 != o2), ""); + static_assert(!(o5 != o3), ""); + static_assert((o5 != o4), ""); + static_assert(!(o5 != o5), ""); + } + { + using O1 = optional<int>; + using O2 = optional<long>; + constexpr O1 o1(42); + static_assert(o1 != O2(101), ""); + static_assert(!(O2(42) != o1), ""); + } + { + using O1 = optional<int>; + using O2 = optional<const int>; + constexpr O1 o1(42); + static_assert(o1 != O2(101), ""); + static_assert(!(O2(42) != o1), ""); + } } diff --git a/test/std/utilities/smartptr/unique.ptr/README.TXT b/test/std/utilities/smartptr/unique.ptr/README.TXT new file mode 100644 index 0000000000000..20f77f61827ce --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/README.TXT @@ -0,0 +1,16 @@ +Test Naming and Directory Structure +=================================== + +The directory structure for the unique_ptr class templates differs from the +normal test directory naming conventions (e.g. matching the stable name in the standard). + +Instead of having a [unique.ptr.single] and [unique.ptr.runtime] directory, +each containing their own tests, a single directory, "unique.ptr.class", +contains both sets of tests. + +This allows the common behavior of the two unique_ptr specializations to be +tested in the same place without duplication. + +Tests specific to [unique.ptr.single] have the suffix ".single.pass.cpp" +and those specific to [unique.ptr.runtime] are named "*.runtime.pass.cpp". +Tests for both specializations are named normally. diff --git a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp index b58f5c55b643a..b58f5c55b643a 100644 --- a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/nothing_to_do.pass.cpp diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp new file mode 100644 index 0000000000000..54c2cf16ecc72 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/pointer_type.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr::pointer type + +#include <memory> +#include <type_traits> + +#include "test_macros.h" + +struct Deleter { + struct pointer {}; +}; + +struct D2 { +private: + typedef void pointer; +}; + +struct D3 { + static long pointer; +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + typedef std::unique_ptr<VT> P; + static_assert((std::is_same<typename P::pointer, int*>::value), ""); + } + { + typedef std::unique_ptr<VT, Deleter> P; + static_assert((std::is_same<typename P::pointer, Deleter::pointer>::value), + ""); + } +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr<VT, D2> P; + static_assert(std::is_same<typename P::pointer, int*>::value, ""); + } + { + typedef std::unique_ptr<VT, D3> P; + static_assert(std::is_same<typename P::pointer, int*>::value, ""); + } +#endif +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp new file mode 100644 index 0000000000000..5d2f955aa185f --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp @@ -0,0 +1,120 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr move assignment + +// test move assignment. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. + +#include <memory> +#include <utility> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +struct GenericDeleter { + void operator()(void*) const; +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s1(newValue<VT>(expect_alive)); + A* p = s1.get(); + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(A::count == expect_alive); + assert(s2.get() == p); + assert(s1.get() == 0); + } + assert(A::count == 0); + { + std::unique_ptr<VT, Deleter<VT> > s1(newValue<VT>(expect_alive), + Deleter<VT>(5)); + A* p = s1.get(); + std::unique_ptr<VT, Deleter<VT> > s2(newValue<VT>(expect_alive)); + assert(A::count == (expect_alive * 2)); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s1.get_deleter().state() == 0); + } + assert(A::count == 0); + { + CDeleter<VT> d1(5); + std::unique_ptr<VT, CDeleter<VT>&> s1(newValue<VT>(expect_alive), d1); + A* p = s1.get(); + CDeleter<VT> d2(6); + std::unique_ptr<VT, CDeleter<VT>&> s2(newValue<VT>(expect_alive), d2); + s2 = std::move(s1); + assert(s2.get() == p); + assert(s1.get() == 0); + assert(A::count == expect_alive); + assert(d1.state() == 5); + assert(d2.state() == 5); + } + assert(A::count == 0); +} + +template <bool IsArray> +void test_sfinae() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + typedef std::unique_ptr<VT> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, GenericDeleter> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, NCDeleter<VT>&> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } + { + typedef std::unique_ptr<VT, const NCDeleter<VT>&> U; + static_assert(!std::is_assignable<U, U&>::value, ""); + static_assert(!std::is_assignable<U, const U&>::value, ""); + static_assert(!std::is_assignable<U, const U&&>::value, ""); + static_assert(std::is_nothrow_assignable<U, U&&>::value, ""); + } +} + + +int main() { + { + test_basic</*IsArray*/ false>(); + test_sfinae<false>(); + } + { + test_basic</*IsArray*/ true>(); + test_sfinae<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp new file mode 100644 index 0000000000000..8d83c3c8888a9 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.pass.cpp @@ -0,0 +1,420 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" +#include "type_id.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + + template <int OID> + GenericConvertingDeleter& operator=(GenericConvertingDeleter<OID> const&) { + return *this; + } + + void operator()(void*) const {} +}; + +template <class T, class U> +using EnableIfNotSame = typename std::enable_if< + !std::is_same<typename std::decay<T>::type, typename std::decay<U>::type>::value +>::type; + +template <class Templ, class Other> +struct is_specialization; + +template <template <int> class Templ, int ID1, class Other> +struct is_specialization<Templ<ID1>, Other> : std::false_type {}; + +template <template <int> class Templ, int ID1, int ID2> +struct is_specialization<Templ<ID1>, Templ<ID2> > : std::true_type {}; + +template <class Templ, class Other> +using EnableIfSpecialization = typename std::enable_if< + is_specialization<Templ, typename std::decay<Other>::type >::value + >::type; + +template <int ID> struct TrackingDeleter; +template <int ID> struct ConstTrackingDeleter; + +template <int ID> +struct TrackingDeleter { + TrackingDeleter() : arg_type(&makeArgumentID<>()) {} + + TrackingDeleter(TrackingDeleter const&) + : arg_type(&makeArgumentID<TrackingDeleter const&>()) {} + + TrackingDeleter(TrackingDeleter&&) + : arg_type(&makeArgumentID<TrackingDeleter &&>()) {} + + template <class T, class = EnableIfSpecialization<TrackingDeleter, T> > + TrackingDeleter(T&&) : arg_type(&makeArgumentID<T&&>()) {} + + TrackingDeleter& operator=(TrackingDeleter const&) { + arg_type = &makeArgumentID<TrackingDeleter const&>(); + return *this; + } + + TrackingDeleter& operator=(TrackingDeleter &&) { + arg_type = &makeArgumentID<TrackingDeleter &&>(); + return *this; + } + + template <class T, class = EnableIfSpecialization<TrackingDeleter, T> > + TrackingDeleter& operator=(T&&) { + arg_type = &makeArgumentID<T&&>(); + return *this; + } + + void operator()(void*) const {} + +public: + TypeID const* reset() const { + TypeID const* tmp = arg_type; + arg_type = nullptr; + return tmp; + } + + mutable TypeID const* arg_type; +}; + +template <int ID> +struct ConstTrackingDeleter { + ConstTrackingDeleter() : arg_type(&makeArgumentID<>()) {} + + ConstTrackingDeleter(ConstTrackingDeleter const&) + : arg_type(&makeArgumentID<ConstTrackingDeleter const&>()) {} + + ConstTrackingDeleter(ConstTrackingDeleter&&) + : arg_type(&makeArgumentID<ConstTrackingDeleter &&>()) {} + + template <class T, class = EnableIfSpecialization<ConstTrackingDeleter, T> > + ConstTrackingDeleter(T&&) : arg_type(&makeArgumentID<T&&>()) {} + + const ConstTrackingDeleter& operator=(ConstTrackingDeleter const&) const { + arg_type = &makeArgumentID<ConstTrackingDeleter const&>(); + return *this; + } + + const ConstTrackingDeleter& operator=(ConstTrackingDeleter &&) const { + arg_type = &makeArgumentID<ConstTrackingDeleter &&>(); + return *this; + } + + template <class T, class = EnableIfSpecialization<ConstTrackingDeleter, T> > + const ConstTrackingDeleter& operator=(T&&) const { + arg_type = &makeArgumentID<T&&>(); + return *this; + } + + void operator()(void*) const {} + +public: + TypeID const* reset() const { + TypeID const* tmp = arg_type; + arg_type = nullptr; + return tmp; + } + + mutable TypeID const* arg_type; +}; + +template <class ExpectT, int ID> +bool checkArg(TrackingDeleter<ID> const& d) { + return d.arg_type && *d.arg_type == makeArgumentID<ExpectT>(); +} + +template <class ExpectT, int ID> +bool checkArg(ConstTrackingDeleter<ID> const& d) { + return d.arg_type && *d.arg_type == makeArgumentID<ExpectT>(); +} + +template <class From, bool AssignIsConst = false> +struct AssignDeleter { + AssignDeleter() = default; + AssignDeleter(AssignDeleter const&) = default; + AssignDeleter(AssignDeleter&&) = default; + + AssignDeleter& operator=(AssignDeleter const&) = delete; + AssignDeleter& operator=(AssignDeleter &&) = delete; + + template <class T> AssignDeleter& operator=(T&&) && = delete; + template <class T> AssignDeleter& operator=(T&&) const && = delete; + + template <class T, class = typename std::enable_if< + std::is_same<T&&, From>::value && !AssignIsConst + >::type> + AssignDeleter& operator=(T&&) & { return *this; } + + template <class T, class = typename std::enable_if< + std::is_same<T&&, From>::value && AssignIsConst + >::type> + const AssignDeleter& operator=(T&&) const & { return *this; } + + template <class T> + void operator()(T) const {} +}; + +template <class VT, class DDest, class DSource> + void doDeleterTest() { + using U1 = std::unique_ptr<VT, DDest>; + using U2 = std::unique_ptr<VT, DSource>; + static_assert(std::is_nothrow_assignable<U1, U2&&>::value, ""); + typename std::decay<DDest>::type ddest; + typename std::decay<DSource>::type dsource; + U1 u1(nullptr, ddest); + U2 u2(nullptr, dsource); + u1 = std::move(u2); +} + +template <bool IsArray> +void test_sfinae() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + + { // Test that different non-reference deleter types are allowed so long + // as they convert to each other. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + static_assert(std::is_assignable<U1, U2&&>::value, ""); + } + { // Test that different non-reference deleter types are disallowed when + // they cannot convert. + using U1 = std::unique_ptr<VT, GenericDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericDeleter<1> >; + static_assert(!std::is_assignable<U1, U2&&>::value, ""); + } + { // Test that if the deleter assignment is not valid the assignment operator + // SFINAEs. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> const& >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(!std::is_assignable<U1, U2&&>::value, ""); + static_assert(!std::is_assignable<U1, U3&&>::value, ""); + static_assert(!std::is_assignable<U1, U4&&>::value, ""); + static_assert(!std::is_assignable<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> const&>; + static_assert(std::is_nothrow_assignable<U1C, U1&&>::value, ""); + } + { // Test that if the deleter assignment is not valid the assignment operator + // SFINAEs. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> & >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + + static_assert(std::is_nothrow_assignable<U1, U2&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U3&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U4&&>::value, ""); + static_assert(std::is_nothrow_assignable<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> &>; + static_assert(std::is_nothrow_assignable<U1C, U1&&>::value, ""); + } + { // Test that non-reference destination deleters can be assigned + // from any source deleter type with a sutible conversion. Including + // reference types. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> const &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> &>; + using U6 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(std::is_assignable<U1, U2&&>::value, ""); + static_assert(std::is_assignable<U1, U3&&>::value, ""); + static_assert(std::is_assignable<U1, U4&&>::value, ""); + static_assert(std::is_assignable<U1, U5&&>::value, ""); + static_assert(std::is_assignable<U1, U6&&>::value, ""); + } + ///////////////////////////////////////////////////////////////////////////// + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del&&>; + using ADC = AssignDeleter<Del&&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del>(); + doDeleterTest<VT, AD&, Del>(); + doDeleterTest<VT, ADC const&, Del>(); + } + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del&>; + using ADC = AssignDeleter<Del&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del&>(); + doDeleterTest<VT, AD&, Del&>(); + doDeleterTest<VT, ADC const&, Del&>(); + } + { + using Del = GenericDeleter<0>; + using AD = AssignDeleter<Del const&>; + using ADC = AssignDeleter<Del const&, /*AllowConstAssign*/true>; + doDeleterTest<VT, AD, Del const&>(); + doDeleterTest<VT, AD&, Del const&>(); + doDeleterTest<VT, ADC const&, Del const&>(); + } +} + + +template <bool IsArray> +void test_noexcept() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + { + typedef std::unique_ptr<const VT> APtr; + typedef std::unique_ptr<VT> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, CDeleter<const VT> > APtr; + typedef std::unique_ptr<VT, CDeleter<VT> > BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, NCDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, NCDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, const NCConstDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, const NCConstDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_assignable<APtr, BPtr>::value, ""); + } +} + +template <bool IsArray> +void test_deleter_value_category() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + using TD1 = TrackingDeleter<1>; + using TD2 = TrackingDeleter<2>; + TD1 d1; + TD2 d2; + using CD1 = ConstTrackingDeleter<1>; + using CD2 = ConstTrackingDeleter<2>; + CD1 cd1; + CD2 cd2; + + { // Test non-reference deleter conversions + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2 >; + U1 u1; + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&&>(u1.get_deleter())); + } + { // Test assignment to non-const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2 >; + U1 u1(nullptr, d1); + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&&>(u1.get_deleter())); + } + { // Test assignment to const&. + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 >; + U1 u1(nullptr, cd1); + U2 u2; + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2&&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2& >; + U1 u1; + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, TD1 >; + using U2 = std::unique_ptr<VT, TD2 const& >; + U1 u1; + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2 const&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2& >; + U1 u1(nullptr, d1); + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2&>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, TD1& >; + using U2 = std::unique_ptr<VT, TD2 const& >; + U1 u1(nullptr, d1); + U2 u2(nullptr, d2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<TD2 const&>(u1.get_deleter())); + } + + { // Test assignment from non-const ref + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 & >; + U1 u1(nullptr, cd1); + U2 u2(nullptr, cd2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2 &>(u1.get_deleter())); + } + { // Test assignment from const ref + using U1 = std::unique_ptr<VT, CD1 const& >; + using U2 = std::unique_ptr<VT, CD2 const& >; + U1 u1(nullptr, cd1); + U2 u2(nullptr, cd2); + u1.get_deleter().reset(); + u1 = std::move(u2); + assert(checkArg<CD2 const&>(u1.get_deleter())); + } +} + +int main() { + { + test_sfinae</*IsArray*/false>(); + test_noexcept<false>(); + test_deleter_value_category<false>(); + } + { + test_sfinae</*IsArray*/true>(); + test_noexcept<true>(); + test_deleter_value_category<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp new file mode 100644 index 0000000000000..9b946a733fea6 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include <memory> +#include <utility> +#include <cassert> + +#include "unique_ptr_test_helper.h" + +template <class APtr, class BPtr> +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A[]>; // non-copyable deleters + using DAC = NCConvertingDeleter<const A[]>; // non-copyable deleters + + using DB = NCConvertingDeleter<B[]>; + using UA = std::unique_ptr<A[]>; + using UAC = std::unique_ptr<const A[]>; + using UB = std::unique_ptr<B[]>; + using UAD = std::unique_ptr<A[], DA>; + using UACD = std::unique_ptr<const A[], DAC>; + + using UBD = std::unique_ptr<B[], DB>; + { // cannot move from an lvalue + static_assert(std::is_assignable<UAC, UA&&>::value, ""); + static_assert(!std::is_assignable<UAC, UA&>::value, ""); + static_assert(!std::is_assignable<UAC, const UA&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable<UACD, UAD&&>::value, ""); + static_assert(!std::is_assignable<UACD, UAC&&>::value, ""); + static_assert(!std::is_assignable<UAC, UACD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A[], DA&>; + using UA2 = std::unique_ptr<A[], DAC&>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A[], const DA&>; + using UA2 = std::unique_ptr<A[], const DAC&>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Single> + using UA1 = std::unique_ptr<A[]>; + using UA2 = std::unique_ptr<A>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A[], NCGenericDeleter>; + using UA2 = std::unique_ptr<A, NCGenericDeleter>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + } +} + +int main() { + test_sfinae(); + // FIXME: add tests +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp new file mode 100644 index 0000000000000..3f2ea422dab33 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.single.pass.cpp @@ -0,0 +1,145 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include <memory> +#include <utility> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template <class APtr, class BPtr> +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A>; // non-copyable deleters + using DB = NCConvertingDeleter<B>; + using UA = std::unique_ptr<A>; + using UB = std::unique_ptr<B>; + using UAD = std::unique_ptr<A, DA>; + using UBD = std::unique_ptr<B, DB>; + { // cannot move from an lvalue + static_assert(std::is_assignable<UA, UB&&>::value, ""); + static_assert(!std::is_assignable<UA, UB&>::value, ""); + static_assert(!std::is_assignable<UA, const UB&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_assignable<UAD, UBD&&>::value, ""); + static_assert(!std::is_assignable<UAD, UB&&>::value, ""); + static_assert(!std::is_assignable<UA, UBD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, DA&>; + using UB1 = std::unique_ptr<B, DB&>; + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, const DA&>; + using UB1 = std::unique_ptr<B, const DB&>; + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A>; + using UA2 = std::unique_ptr<A[]>; + using UB1 = std::unique_ptr<B[]>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A, NCGenericDeleter>; + using UA2 = std::unique_ptr<A[], NCGenericDeleter>; + using UB1 = std::unique_ptr<B[], NCGenericDeleter>; + static_assert(!std::is_assignable<UA1, UA2&&>::value, ""); + static_assert(!std::is_assignable<UA1, UB1&&>::value, ""); + } +} + +int main() { + test_sfinae(); + { + std::unique_ptr<B> bptr(new B); + std::unique_ptr<A> aptr(new A); + testAssign(aptr, bptr); + } + assert(A::count == 0); + assert(B::count == 0); + { + Deleter<B> del(42); + std::unique_ptr<B, Deleter<B> > bptr(new B, std::move(del)); + std::unique_ptr<A, Deleter<A> > aptr(new A); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 0); + } + assert(A::count == 0); + assert(B::count == 0); + { + CDeleter<A> adel(6); + CDeleter<B> bdel(42); + std::unique_ptr<B, CDeleter<B>&> bptr(new B, bdel); + std::unique_ptr<A, CDeleter<A>&> aptr(new A, adel); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 42); + } + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp index e2d7956cda643..165d48a1caa53 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/null.pass.cpp @@ -16,26 +16,24 @@ #include <memory> #include <cassert> -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; +#include "unique_ptr_test_helper.h" -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; +// test assignment from null +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + s2 = NULL; assert(A::count == 0); assert(s2.get() == 0); - } - assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp index fb15849519938..e1e2e32e23c48 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/nullptr.pass.cpp @@ -16,26 +16,25 @@ #include <memory> #include <cassert> +#include "unique_ptr_test_helper.h" + // test assignment from null -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + std::unique_ptr<VT> s2(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); s2 = nullptr; assert(A::count == 0); assert(s2.get() == 0); - } - assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp new file mode 100644 index 0000000000000..7d5e9bca63c45 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// libc++ cannot safely provide the auto_ptr constructor without rvalue +// references. +// REQUIRES: c++11 || c++14 + +// <memory> + +// unique_ptr + +// template <class U> unique_ptr(auto_ptr<U>&&) noexcept + +#include <memory> +#include <utility> +#include <cassert> + +#include "test_macros.h" + +struct A { + static int count; + A() { ++count; } + A(const A&) { ++count; } + virtual ~A() { --count; } +}; + +int A::count = 0; + +struct B : public A { + static int count; + B() { ++count; } + B(const B&) { ++count; } + virtual ~B() { --count; } +}; + +int B::count = 0; + +struct C {}; + +struct Deleter { + void operator()(void*) {} +}; + +void test_sfinae() { + { + // the auto_ptr constructor should be disable with a non-default deleter. + using AP = std::auto_ptr<int>; + using U = std::unique_ptr<int, Deleter>; + static_assert(!std::is_constructible<U, AP&&>::value, ""); + } + { + // the auto_ptr constructor should be disabled when the pointer types are incompatible. + using AP = std::auto_ptr<A>; + using U = std::unique_ptr<C>; + static_assert(!std::is_constructible<U, AP&&>::value, ""); + } +} + +int main() { + { + B* p = new B; + std::auto_ptr<B> ap(p); + std::unique_ptr<A> up(std::move(ap)); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + std::auto_ptr<B> ap(p); + std::unique_ptr<A> up; + up = std::move(ap); + assert(up.get() == p); + assert(ap.get() == 0); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +#if TEST_STD_VER >= 11 + { + static_assert(std::is_nothrow_constructible<std::unique_ptr<A>, + std::auto_ptr<B>&&>::value, + ""); + } +#endif + test_sfinae(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp new file mode 100644 index 0000000000000..51d9aa708c407 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp @@ -0,0 +1,107 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr() +// +// Concerns: +// 1 The default constructor works for any default constructible deleter types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Default construct unique_ptr's with various deleter types (C-1) +// 2 Default construct a unique_ptr with an incomplete element_type and +// various deleter types (C-1,2) + +#include <memory> +#include <cassert> +#include "test_macros.h" + +#include "test_macros.h" +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 +_LIBCPP_SAFE_STATIC std::unique_ptr<int> global_static_unique_ptr_single; +_LIBCPP_SAFE_STATIC std::unique_ptr<int[]> global_static_unique_ptr_runtime; +#endif + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template <class ElemType> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<ElemType, void (*)(void*)>; + static_assert(!std::is_default_constructible<U>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<ElemType>; + using U1 = std::unique_ptr<ElemType, NonDefaultDeleter>; + using U2 = std::unique_ptr<ElemType, Del&>; + using U3 = std::unique_ptr<ElemType, Del const&>; + static_assert(!std::is_default_constructible<U1>::value, ""); + static_assert(!std::is_default_constructible<U2>::value, ""); + static_assert(!std::is_default_constructible<U3>::value, ""); + } +#endif +} + +template <class ElemType> +void test_basic() { +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<ElemType>; + using U2 = std::unique_ptr<ElemType, Deleter<ElemType> >; + static_assert(std::is_nothrow_default_constructible<U1>::value, ""); + static_assert(std::is_nothrow_default_constructible<U2>::value, ""); + } +#endif + { + std::unique_ptr<ElemType> p; + assert(p.get() == 0); + } + { + std::unique_ptr<ElemType, NCDeleter<ElemType> > p; + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + p.get_deleter().set_state(5); + assert(p.get_deleter().state() == 5); + } +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + doIncompleteTypeTest(0); + doIncompleteTypeTest<IncompleteType, Deleter<IncompleteType> >(0); +} { + doIncompleteTypeTest<IncompleteType[]>(0); + doIncompleteTypeTest<IncompleteType[], Deleter<IncompleteType[]> >(0); +}) + +int main() { + { + test_sfinae<int>(); + test_basic<int>(); + } + { + test_sfinae<int[]>(); + test_basic<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp new file mode 100644 index 0000000000000..c102f27fb8e6d --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp @@ -0,0 +1,174 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr move ctor + +#include <memory> +#include <utility> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +//============================================================================= +// TESTING unique_ptr(unique_ptr&&) +// +// Concerns +// 1 The moved from pointer is empty and the new pointer stores the old value. +// 2 The only requirement on the deleter is that it is MoveConstructible +// or a reference. +// 3 The constructor works for explicitly moved values (ie std::move(x)) +// 4 The constructor works for true temporaries (ie a return value) +// +// Plan +// 1 Explicitly construct unique_ptr<T, D> for various deleter types 'D'. +// check that the value and deleter have been properly moved. (C-1,2,3) +// +// 2 Use the expression 'sink(source())' to move construct a unique_ptr<T, D> +// from a temporary. 'source' should return the unique_ptr by value and +// 'sink' should accept the unique_ptr by value. (C-1,2,4) + +template <class VT> +std::unique_ptr<VT> source1() { + return std::unique_ptr<VT>(newValue<VT>(1)); +} + +template <class VT> +std::unique_ptr<VT, Deleter<VT> > source2() { + return std::unique_ptr<VT, Deleter<VT> >(newValue<VT>(1), Deleter<VT>(5)); +} + +template <class VT> +std::unique_ptr<VT, NCDeleter<VT>&> source3() { + static NCDeleter<VT> d(5); + return std::unique_ptr<VT, NCDeleter<VT>&>(newValue<VT>(1), d); +} + +template <class VT> +void sink1(std::unique_ptr<VT> p) { + assert(p.get() != nullptr); +} + +template <class VT> +void sink2(std::unique_ptr<VT, Deleter<VT> > p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); +} + +template <class VT> +void sink3(std::unique_ptr<VT, NCDeleter<VT>&> p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); + assert(&p.get_deleter() == &source3<VT>().get_deleter()); +} + +template <class ValueT> +void test_sfinae() { + typedef std::unique_ptr<ValueT> U; + { // Ensure unique_ptr is non-copyable + static_assert((!std::is_constructible<U, U const&>::value), ""); + static_assert((!std::is_constructible<U, U&>::value), ""); + } +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { + typedef std::unique_ptr<VT> APtr; + APtr s(newValue<VT>(expect_alive)); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + } + assert(A::count == 0); + { + typedef Deleter<VT> MoveDel; + typedef std::unique_ptr<VT, MoveDel> APtr; + MoveDel d(5); + APtr s(newValue<VT>(expect_alive), std::move(d)); + assert(d.state() == 0); + assert(s.get_deleter().state() == 5); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + assert(s2.get_deleter().state() == 5); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + { + typedef NCDeleter<VT> NonCopyDel; + typedef std::unique_ptr<VT, NonCopyDel&> APtr; + + NonCopyDel d; + APtr s(newValue<VT>(expect_alive), d); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == expect_alive); + d.set_state(6); + assert(s2.get_deleter().state() == d.state()); + assert(s.get_deleter().state() == d.state()); + } + assert(A::count == 0); + { + sink1<VT>(source1<VT>()); + assert(A::count == 0); + sink2<VT>(source2<VT>()); + assert(A::count == 0); + sink3<VT>(source3<VT>()); + assert(A::count == 0); + } + assert(A::count == 0); +} + +template <class VT> +void test_noexcept() { +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr<VT> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, Deleter<VT> > U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, NCDeleter<VT> &> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } + { + typedef std::unique_ptr<VT, const NCConstDeleter<VT> &> U; + static_assert(std::is_nothrow_move_constructible<U>::value, ""); + } +#endif +} + +int main() { + { + test_basic</*IsArray*/ false>(); + test_sfinae<int>(); + test_noexcept<int>(); + } + { + test_basic</*IsArray*/ true>(); + test_sfinae<int[]>(); + test_noexcept<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp new file mode 100644 index 0000000000000..6e5db86c97fc4 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + void operator()(void*) const {} +}; + +template <bool IsArray> +void test_sfinae() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<IsArray, A[], A>::type VT; + + { // Test that different non-reference deleter types are allowed so long + // as they convert to each other. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + } + { // Test that different non-reference deleter types are disallowed when + // they cannot convert. + using U1 = std::unique_ptr<VT, GenericDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericDeleter<1> >; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + } + { // Test that if the destination deleter is a reference type then only + // exact matches are allowed. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> const& >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U1, U3&&>::value, ""); + static_assert(!std::is_constructible<U1, U4&&>::value, ""); + static_assert(!std::is_constructible<U1, U5&&>::value, ""); + + using U1C = std::unique_ptr<const VT, GenericConvertingDeleter<0> const&>; + static_assert(std::is_nothrow_constructible<U1C, U1&&>::value, ""); + } + { // Test that non-reference destination deleters can be constructed + // from any source deleter type with a sutible conversion. Including + // reference types. + using U1 = std::unique_ptr<VT, GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<VT, GenericConvertingDeleter<0> &>; + using U3 = std::unique_ptr<VT, GenericConvertingDeleter<0> const &>; + using U4 = std::unique_ptr<VT, GenericConvertingDeleter<1> >; + using U5 = std::unique_ptr<VT, GenericConvertingDeleter<1> &>; + using U6 = std::unique_ptr<VT, GenericConvertingDeleter<1> const&>; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(std::is_constructible<U1, U3&&>::value, ""); + static_assert(std::is_constructible<U1, U4&&>::value, ""); + static_assert(std::is_constructible<U1, U5&&>::value, ""); + static_assert(std::is_constructible<U1, U6&&>::value, ""); + } +#endif +} + + +template <bool IsArray> +void test_noexcept() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<IsArray, A[], A>::type VT; + { + typedef std::unique_ptr<const VT> APtr; + typedef std::unique_ptr<VT> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, CDeleter<const VT> > APtr; + typedef std::unique_ptr<VT, CDeleter<VT> > BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, NCDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, NCDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<const VT, const NCConstDeleter<const VT>&> APtr; + typedef std::unique_ptr<VT, const NCConstDeleter<const VT>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } +#endif +} + + +int main() { + { + test_sfinae</*IsArray*/false>(); + test_noexcept<false>(); + } + { + test_sfinae</*IsArray*/true>(); + test_noexcept<true>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp new file mode 100644 index 0000000000000..09e842b5987f5 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.runtime.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +#include <memory> +#include <cassert> + +#include "deleter_types.h" +#include "unique_ptr_test_helper.h" + +template <int ID = 0> +struct GenericDeleter { + void operator()(void*) const {} +}; + +template <int ID = 0> +struct GenericConvertingDeleter { + template <int OID> + GenericConvertingDeleter(GenericConvertingDeleter<OID>) {} + void operator()(void*) const {} +}; + +void test_sfinae() { + { // Disallow copying + using U1 = std::unique_ptr<A[], GenericConvertingDeleter<0> >; + using U2 = std::unique_ptr<A[], GenericConvertingDeleter<1> >; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U1, U2&>::value, ""); + static_assert(!std::is_constructible<U1, const U2&>::value, ""); + static_assert(!std::is_constructible<U1, const U2&&>::value, ""); + } + { // Disallow illegal qualified conversions + using U1 = std::unique_ptr<const A[]>; + using U2 = std::unique_ptr<A[]>; + static_assert(std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr<A[]>; + using UB = std::unique_ptr<B[]>; + static_assert(!std::is_constructible<UA, UB&&>::value, ""); + } + { // Disallow base-to-derived conversions. + using UA = std::unique_ptr<A[], GenericConvertingDeleter<0> >; + using UB = std::unique_ptr<B[], GenericConvertingDeleter<1> >; + static_assert(!std::is_constructible<UA, UB&&>::value, ""); + } + { // Disallow invalid deleter initialization + using U1 = std::unique_ptr<A[], GenericDeleter<0> >; + using U2 = std::unique_ptr<A[], GenericDeleter<1> >; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + } + { // Disallow reference deleters with different qualifiers + using U1 = std::unique_ptr<A[], Deleter<A[]>&>; + using U2 = std::unique_ptr<A[], const Deleter<A[]>&>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } + { + using U1 = std::unique_ptr<A[]>; + using U2 = std::unique_ptr<A>; + static_assert(!std::is_constructible<U1, U2&&>::value, ""); + static_assert(!std::is_constructible<U2, U1&&>::value, ""); + } +} + + +int main() { + test_sfinae(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp new file mode 100644 index 0000000000000..4e2a6dfa3dd11 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move_convert.single.pass.cpp @@ -0,0 +1,248 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// + +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// Test unique_ptr converting move ctor + +// NOTE: unique_ptr does not provide converting constructors in c++03 +// UNSUPPORTED: c++98, c++03 + +#include <memory> +#include <type_traits> +#include <utility> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +// test converting move ctor. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. +// Explicit version + +template <class LHS, class RHS> +void checkReferenceDeleter(LHS& lhs, RHS& rhs) { + typedef typename LHS::deleter_type NewDel; + static_assert(std::is_reference<NewDel>::value, ""); + rhs.get_deleter().set_state(42); + assert(rhs.get_deleter().state() == 42); + assert(lhs.get_deleter().state() == 42); + lhs.get_deleter().set_state(99); + assert(lhs.get_deleter().state() == 99); + assert(rhs.get_deleter().state() == 99); +} + +template <class LHS, class RHS> +void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { + assert(lhs.get_deleter().state() == LHSVal); + assert(rhs.get_deleter().state() == RHSVal); +} + +template <class LHS, class RHS> +void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { + assert(lhs.get() == RHSVal); + assert(rhs.get() == nullptr); + assert(A::count == 1); + assert(B::count == 1); +} + +void checkNoneAlive() { + assert(A::count == 0); + assert(B::count == 0); +} + +template <class T> +struct NCConvertingDeleter { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +template <class T> +struct NCConvertingDeleter<T[]> { + NCConvertingDeleter() = default; + NCConvertingDeleter(NCConvertingDeleter const&) = delete; + NCConvertingDeleter(NCConvertingDeleter&&) = default; + + template <class U> + NCConvertingDeleter(NCConvertingDeleter<U>&&) {} + + void operator()(T*) const {} +}; + +struct NCGenericDeleter { + NCGenericDeleter() = default; + NCGenericDeleter(NCGenericDeleter const&) = delete; + NCGenericDeleter(NCGenericDeleter&&) = default; + + void operator()(void*) const {} +}; + +void test_sfinae() { + using DA = NCConvertingDeleter<A>; // non-copyable deleters + using DB = NCConvertingDeleter<B>; + using UA = std::unique_ptr<A>; + using UB = std::unique_ptr<B>; + using UAD = std::unique_ptr<A, DA>; + using UBD = std::unique_ptr<B, DB>; + { // cannot move from an lvalue + static_assert(std::is_constructible<UA, UB&&>::value, ""); + static_assert(!std::is_constructible<UA, UB&>::value, ""); + static_assert(!std::is_constructible<UA, const UB&>::value, ""); + } + { // cannot move if the deleter-types cannot convert + static_assert(std::is_constructible<UAD, UBD&&>::value, ""); + static_assert(!std::is_constructible<UAD, UB&&>::value, ""); + static_assert(!std::is_constructible<UA, UBD&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, DA&>; + using UB1 = std::unique_ptr<B, DB&>; + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert with reference deleters of different types + using UA1 = std::unique_ptr<A, const DA&>; + using UB1 = std::unique_ptr<B, const DB&>; + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A>; + using UA2 = std::unique_ptr<A[]>; + using UB1 = std::unique_ptr<B[]>; + static_assert(!std::is_constructible<UA1, UA2&&>::value, ""); + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } + { // cannot move-convert from unique_ptr<Array[]> + using UA1 = std::unique_ptr<A, NCGenericDeleter>; + using UA2 = std::unique_ptr<A[], NCGenericDeleter>; + using UB1 = std::unique_ptr<B[], NCGenericDeleter>; + static_assert(!std::is_constructible<UA1, UA2&&>::value, ""); + static_assert(!std::is_constructible<UA1, UB1&&>::value, ""); + } +} + +void test_noexcept() { + { + typedef std::unique_ptr<A> APtr; + typedef std::unique_ptr<B> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, Deleter<A> > APtr; + typedef std::unique_ptr<B, Deleter<B> > BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, NCDeleter<A>&> APtr; + typedef std::unique_ptr<B, NCDeleter<A>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } + { + typedef std::unique_ptr<A, const NCConstDeleter<A>&> APtr; + typedef std::unique_ptr<B, const NCConstDeleter<A>&> BPtr; + static_assert(std::is_nothrow_constructible<APtr, BPtr>::value, ""); + } +} + +int main() { + { + test_sfinae(); + test_noexcept(); + } + { + typedef std::unique_ptr<A> APtr; + typedef std::unique_ptr<B> BPtr; + { // explicit + BPtr b(new B); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + } + checkNoneAlive(); + { // implicit + BPtr b(new B); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + } + checkNoneAlive(); + } + { // test with moveable deleters + typedef std::unique_ptr<A, Deleter<A> > APtr; + typedef std::unique_ptr<B, Deleter<B> > BPtr; + { + Deleter<B> del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + { + Deleter<B> del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + } + { // test with reference deleters + typedef std::unique_ptr<A, NCDeleter<A>&> APtr; + typedef std::unique_ptr<B, NCDeleter<A>&> BPtr; + NCDeleter<A> del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + } + { + typedef std::unique_ptr<A, CDeleter<A> > APtr; + typedef std::unique_ptr<B, CDeleter<B>&> BPtr; + CDeleter<B> del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp new file mode 100644 index 0000000000000..8bc8a57c1c8d8 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <memory> + +// unique_ptr + +// FIXME(EricWF): This test contains tests for constructing a unique_ptr from NULL. +// The behavior demonstrated in this test is not meant to be standard; It simply +// tests the current status quo in libc++. + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <class VT> +void test_pointer_ctor() { + { + std::unique_ptr<VT> p(0); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, Deleter<VT> > p(0); + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + } +} + +template <class VT> +void test_pointer_deleter_ctor() { + { + std::default_delete<VT> d; + std::unique_ptr<VT> p(0, d); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, Deleter<VT> > p(0, Deleter<VT>(5)); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCDeleter<VT> d(5); + std::unique_ptr<VT, NCDeleter<VT>&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } + { + NCConstDeleter<VT> d(5); + std::unique_ptr<VT, NCConstDeleter<VT> const&> p(0, d); + assert(p.get() == 0); + assert(p.get_deleter().state() == 5); + } +} + +int main() { + { + // test_pointer_ctor<int>(); + test_pointer_deleter_ctor<int>(); + } + { + test_pointer_ctor<int[]>(); + test_pointer_deleter_ctor<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp new file mode 100644 index 0000000000000..6764935fee14c --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp @@ -0,0 +1,106 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// unique_ptr(nullptr_t); + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + + +#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11 +_LIBCPP_SAFE_STATIC std::unique_ptr<int> global_static_unique_ptr_single(nullptr); +_LIBCPP_SAFE_STATIC std::unique_ptr<int[]> global_static_unique_ptr_runtime(nullptr); +#endif + + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; +#endif + +template <class VT> +void test_basic() { +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<VT>; + using U2 = std::unique_ptr<VT, Deleter<VT> >; + static_assert(std::is_nothrow_constructible<U1, decltype(nullptr)>::value, + ""); + static_assert(std::is_nothrow_constructible<U2, decltype(nullptr)>::value, + ""); + } +#endif + { + std::unique_ptr<VT> p(nullptr); + assert(p.get() == 0); + } + { + std::unique_ptr<VT, NCDeleter<VT> > p(nullptr); + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + } +} + +template <class VT> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<VT, void (*)(void*)>; + static_assert(!std::is_constructible<U, decltype(nullptr)>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<VT>; + using U1 = std::unique_ptr<VT, NonDefaultDeleter>; + using U2 = std::unique_ptr<VT, Del&>; + using U3 = std::unique_ptr<VT, Del const&>; + static_assert(!std::is_constructible<U1, decltype(nullptr)>::value, ""); + static_assert(!std::is_constructible<U2, decltype(nullptr)>::value, ""); + static_assert(!std::is_constructible<U3, decltype(nullptr)>::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType, NCDeleter<IncompleteType> >(0, + nullptr); + } + checkNumIncompleteTypeAlive(0); + { doIncompleteTypeTest<IncompleteType[]>(0, nullptr); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType[], NCDeleter<IncompleteType[]> >( + 0, nullptr); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_basic<int>(); + test_sfinae<int>(); + } + { + test_basic<int[]>(); + test_sfinae<int[]>(); + } +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp new file mode 100644 index 0000000000000..8df259bd4e1d1 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer.pass.cpp @@ -0,0 +1,171 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr(pointer) +// +// Concerns: +// 1 The pointer constructor works for any default constructible deleter types. +// 2 The pointer constructor accepts pointers to derived types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Construct unique_ptr<T, D>'s with a pointer to 'T' and various deleter +// types (C-1) +// 2 Construct unique_ptr<T, D>'s with a pointer to 'D' and various deleter +// types where 'D' is derived from 'T'. (C-1,2) +// 3 Construct a unique_ptr<T, D> with a pointer to 'T' and various deleter +// types where 'T' is an incomplete type (C-1,3) + +// Test unique_ptr(pointer) ctor + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +// unique_ptr(pointer) ctor should only require default Deleter ctor + +template <bool IsArray> +void test_pointer() { + typedef typename std::conditional<!IsArray, A, A[]>::type ValueT; + const int expect_alive = IsArray ? 5 : 1; +#if TEST_STD_VER >= 11 + { + using U1 = std::unique_ptr<ValueT>; + using U2 = std::unique_ptr<ValueT, Deleter<ValueT> >; + + // Test for noexcept + static_assert(std::is_nothrow_constructible<U1, A*>::value, ""); + static_assert(std::is_nothrow_constructible<U2, A*>::value, ""); + + // Test for explicit + static_assert(!std::is_convertible<A*, U1>::value, ""); + static_assert(!std::is_convertible<A*, U2>::value, ""); + } +#endif + { + A* p = newValue<ValueT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<ValueT> s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = newValue<ValueT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<ValueT, NCDeleter<ValueT> > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); +} + +void test_derived() { + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A> s(p); + assert(s.get() == p); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A, NCDeleter<A> > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + assert(B::count == 0); +} + +#if TEST_STD_VER >= 11 +struct NonDefaultDeleter { + NonDefaultDeleter() = delete; + void operator()(void*) const {} +}; + +struct GenericDeleter { + void operator()(void*) const; +}; +#endif + +template <class T> +void test_sfinae() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resultion when + // the deleter is a pointer type + using U = std::unique_ptr<T, void (*)(void*)>; + static_assert(!std::is_constructible<U, T*>::value, ""); + } + { // the constructor does not participate in overload resolution when + // the deleter is not default constructible + using Del = CDeleter<T>; + using U1 = std::unique_ptr<T, NonDefaultDeleter>; + using U2 = std::unique_ptr<T, Del&>; + using U3 = std::unique_ptr<T, Del const&>; + static_assert(!std::is_constructible<U1, T*>::value, ""); + static_assert(!std::is_constructible<U2, T*>::value, ""); + static_assert(!std::is_constructible<U3, T*>::value, ""); + } +#endif +} + +static void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 + { // the constructor does not participate in overload resolution when + // a base <-> derived conversion would occur. + using UA = std::unique_ptr<A[]>; + using UAD = std::unique_ptr<A[], GenericDeleter>; + using UAC = std::unique_ptr<const A[]>; + using UB = std::unique_ptr<B[]>; + using UBD = std::unique_ptr<B[], GenericDeleter>; + using UBC = std::unique_ptr<const B[]>; + + static_assert(!std::is_constructible<UA, B*>::value, ""); + static_assert(!std::is_constructible<UB, A*>::value, ""); + static_assert(!std::is_constructible<UAD, B*>::value, ""); + static_assert(!std::is_constructible<UBD, A*>::value, ""); + static_assert(!std::is_constructible<UAC, const B*>::value, ""); + static_assert(!std::is_constructible<UBC, const A*>::value, ""); + } +#endif +} + +DEFINE_AND_RUN_IS_INCOMPLETE_TEST({ + { doIncompleteTypeTest(1, getNewIncomplete()); } + checkNumIncompleteTypeAlive(0); + { + doIncompleteTypeTest<IncompleteType, NCDeleter<IncompleteType> >( + 1, getNewIncomplete()); + } + checkNumIncompleteTypeAlive(0); +}) + +int main() { + { + test_pointer</*IsArray*/ false>(); + test_derived(); + test_sfinae<int>(); + } + { + test_pointer</*IsArray*/ true>(); + test_sfinae<int[]>(); + test_sfinae_runtime(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp index ad64b5e4ea395..b4cd3f36ab573 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.fail.cpp @@ -20,11 +20,10 @@ #include <memory> struct Deleter { - void operator()(int* p) const {delete p;} + void operator()(int* p) const { delete p; } }; -int main() -{ - // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} - std::unique_ptr<int, const Deleter&> s((int*)nullptr, Deleter()); // expected-note {{requested here}} +int main() { + // expected-error@+1 {{call to deleted constructor of 'std::unique_ptr<int, const Deleter &>}} + std::unique_ptr<int, const Deleter&> s((int*)nullptr, Deleter()); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp new file mode 100644 index 0000000000000..781794d41b5e3 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/pointer_deleter.pass.cpp @@ -0,0 +1,328 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +//============================================================================= +// TESTING unique_ptr(pointer, deleter) +// +// Concerns: +// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. +// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. +// 3 unique_ptr<T, D&>(pointer, deleter) does not require a CopyConstructible deleter. +// 4 unique_ptr<T, D const&>(pointer, deleter) does not require a CopyConstructible deleter. +// 5 unique_ptr(pointer, deleter) should work for derived pointers. +// 6 unique_ptr(pointer, deleter) should work with function pointers. +// 7 unique_ptr<void> should work. + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +bool my_free_called = false; + +void my_free(void*) { my_free_called = true; } + +#if TEST_STD_VER >= 11 +struct DeleterBase { + void operator()(void*) const {} +}; +struct CopyOnlyDeleter : DeleterBase { + CopyOnlyDeleter() = default; + CopyOnlyDeleter(CopyOnlyDeleter const&) = default; + CopyOnlyDeleter(CopyOnlyDeleter&&) = delete; +}; +struct MoveOnlyDeleter : DeleterBase { + MoveOnlyDeleter() = default; + MoveOnlyDeleter(MoveOnlyDeleter&&) = default; +}; +struct NoCopyMoveDeleter : DeleterBase { + NoCopyMoveDeleter() = default; + NoCopyMoveDeleter(NoCopyMoveDeleter const&) = delete; +}; +#endif + +template <bool IsArray> +void test_sfinae() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, int, int[]>::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(std::is_constructible<U, int*, D&&>::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&>::value, ""); + static_assert(std::is_constructible<U, int*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D&>; + static_assert(!std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + static_assert(!std::is_constructible<U, int*, const D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, const D&>; + static_assert(std::is_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_constructible<U, int*, D&>::value, ""); + static_assert(!std::is_constructible<U, int*, D&&>::value, ""); + static_assert(!std::is_constructible<U, int*, const D&&>::value, ""); + } +#endif +} + +template <bool IsArray> +void test_noexcept() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, int, int[]>::type VT; + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_nothrow_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&&>::value, ""); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<VT, D>; + static_assert(std::is_nothrow_constructible<U, int*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, D&>; + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<VT, const D&>; + static_assert(std::is_nothrow_constructible<U, int*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, int*, D&>::value, ""); + } +#endif +} + +void test_sfinae_runtime() { +#if TEST_STD_VER >= 11 + { + using D = CopyOnlyDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(std::is_nothrow_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + // FIXME: __libcpp_compressed_pair attempts to perform a move even though + // it should only copy. + //D d; + //U u(nullptr, std::move(d)); + } + { + using D = MoveOnlyDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + D d; + U u(nullptr, std::move(d)); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], D>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], D&>; + static_assert(!std::is_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + static_assert(!std::is_constructible<U, A*, const D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + static_assert(!std::is_constructible<U, B*, const D&&>::value, ""); + } + { + using D = NoCopyMoveDeleter; + using U = std::unique_ptr<A[], const D&>; + static_assert(std::is_nothrow_constructible<U, A*, D const&>::value, ""); + static_assert(std::is_nothrow_constructible<U, A*, D&>::value, ""); + static_assert(!std::is_constructible<U, A*, D&&>::value, ""); + static_assert(!std::is_constructible<U, A*, const D&&>::value, ""); + + static_assert(!std::is_constructible<U, B*, D const&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&>::value, ""); + static_assert(!std::is_constructible<U, B*, D&&>::value, ""); + static_assert(!std::is_constructible<U, B*, const D&&>::value, ""); + } +#endif +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + const int expect_alive = IsArray ? 5 : 1; + { // MoveConstructible deleter (C-1) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + std::unique_ptr<VT, Deleter<VT> > s(p, Deleter<VT>(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // CopyConstructible deleter (C-2) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + CopyDeleter<VT> d(5); + std::unique_ptr<VT, CopyDeleter<VT> > s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // Reference deleter (C-3) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + NCDeleter<VT> d(5); + std::unique_ptr<VT, NCDeleter<VT>&> s(p, d); + assert(s.get() == p); + assert(&s.get_deleter() == &d); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 6); + } + assert(A::count == 0); + { // Const Reference deleter (C-4) + A* p = newValue<VT>(expect_alive); + assert(A::count == expect_alive); + NCConstDeleter<VT> d(5); + std::unique_ptr<VT, NCConstDeleter<VT> const&> s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + assert(&s.get_deleter() == &d); + } + assert(A::count == 0); + { // Void and function pointers (C-6,7) + typedef typename std::conditional<IsArray, int[], int>::type VT2; + my_free_called = false; + { + int i = 0; + std::unique_ptr<VT2, void (*)(void*)> s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +void test_basic_single() { + assert(A::count == 0); + assert(B::count == 0); + { // Derived pointers (C-5) + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + assert(B::count == 0); + { // Void and function pointers (C-6,7) + my_free_called = false; + { + int i = 0; + std::unique_ptr<void, void (*)(void*)> s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} + +template <bool IsArray> +void test_nullptr() { +#if TEST_STD_VER >= 11 + typedef typename std::conditional<!IsArray, A, A[]>::type VT; + { + std::unique_ptr<VT, Deleter<VT> > u(nullptr, Deleter<VT>{}); + assert(u.get() == nullptr); + } + { + NCDeleter<VT> d; + std::unique_ptr<VT, NCDeleter<VT>& > u(nullptr, d); + assert(u.get() == nullptr); + } + { + NCConstDeleter<VT> d; + std::unique_ptr<VT, NCConstDeleter<VT> const& > u(nullptr, d); + assert(u.get() == nullptr); + } +#endif +} + +int main() { + { + test_basic</*IsArray*/ false>(); + test_nullptr<false>(); + test_basic_single(); + test_sfinae<false>(); + test_noexcept<false>(); + } + { + test_basic</*IsArray*/ true>(); + test_nullptr<true>(); + test_sfinae<true>(); + test_sfinae_runtime(); + test_noexcept<true>(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp index 064f38c5f167f..fa10ade512064 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.dtor/null.pass.cpp @@ -16,29 +16,33 @@ #include <memory> #include <cassert> -class Deleter -{ - int state_; +class Deleter { + int state_; - Deleter(Deleter&); - Deleter& operator=(Deleter&); + Deleter(Deleter&); + Deleter& operator=(Deleter&); public: - Deleter() : state_(0) {} + Deleter() : state_(0) {} - int state() const {return state_;} + int state() const { return state_; } - void operator()(void*) {++state_;} + void operator()(void*) { ++state_; } }; -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int, Deleter&> p(0, d); - assert(p.get() == 0); +template <class T> +void test_basic() { + Deleter d; + assert(d.state() == 0); + { + std::unique_ptr<T, Deleter&> p(nullptr, d); + assert(p.get() == nullptr); assert(&p.get_deleter() == &d); - } - assert(d.state() == 0); + } + assert(d.state() == 0); +} + +int main() { + test_basic<int>(); + test_basic<int[]>(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp new file mode 100644 index 0000000000000..f7f20945094e8 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/release.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test release + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.release()); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* ap = p.get(); + A* a = p.release(); + assert(A::count == expect_alive); + assert(p.get() == nullptr); + assert(ap == a); + assert(a != nullptr); + + if (IsArray) + delete[] a; + else + delete a; + + assert(A::count == 0); + } + assert(A::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp new file mode 100644 index 0000000000000..c95c55b4adf88 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.pass.cpp @@ -0,0 +1,117 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test reset + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_reset_pointer() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset((A*)nullptr)); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + A* new_value = newValue<VT>(expect_alive); + assert(A::count == (expect_alive * 2)); + p.reset(new_value); + assert(A::count == expect_alive); + assert(p.get() == new_value); + } + assert(A::count == 0); + { + std::unique_ptr<const VT> p(newValue<const VT>(expect_alive)); + assert(A::count == expect_alive); + const A* i = p.get(); + assert(i != nullptr); + A* new_value = newValue<VT>(expect_alive); + assert(A::count == (expect_alive * 2)); + p.reset(new_value); + assert(A::count == expect_alive); + assert(p.get() == new_value); + } + assert(A::count == 0); +} + +template <bool IsArray> +void test_reset_nullptr() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset(nullptr)); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + p.reset(nullptr); + assert(A::count == 0); + assert(p.get() == nullptr); + } + assert(A::count == 0); +} + + +template <bool IsArray> +void test_reset_no_arg() { + typedef typename std::conditional<IsArray, A[], A>::type VT; + const int expect_alive = IsArray ? 3 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT>; + U u; ((void)u); + ASSERT_NOEXCEPT(u.reset()); + } +#endif + { + std::unique_ptr<VT> p(newValue<VT>(expect_alive)); + assert(A::count == expect_alive); + A* i = p.get(); + assert(i != nullptr); + p.reset(); + assert(A::count == 0); + assert(p.get() == nullptr); + } + assert(A::count == 0); +} + +int main() { + { + test_reset_pointer</*IsArray*/ false>(); + test_reset_nullptr<false>(); + test_reset_no_arg<false>(); + } + { + test_reset_pointer</*IsArray*/true>(); + test_reset_nullptr<true>(); + test_reset_no_arg<true>(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp index 9ec9b9527e8ab..0d067b9abff5b 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.runtime.fail.cpp @@ -11,29 +11,20 @@ // unique_ptr -// test op*() +// test reset #include <memory> #include <cassert> -int main() -{ - { - std::unique_ptr<int[]> p(new int [3]); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { +#include "unique_ptr_test_helper.h" + +int main() { + { + std::unique_ptr<A[]> p; + p.reset(static_cast<B*>(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } + { std::unique_ptr<int[]> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } + p.reset(static_cast<const int*>(nullptr)); // expected-error {{no matching member function for call to 'reset'}} + } } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp index 2de7787b267e4..8f2a69913dde0 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset.single.pass.cpp @@ -16,30 +16,10 @@ #include <memory> #include <cassert> -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; +#include "unique_ptr_test_helper.h" -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { +int main() { + { std::unique_ptr<A> p(new A); assert(A::count == 1); assert(B::count == 0); @@ -48,10 +28,10 @@ int main() p.reset(new B); assert(A::count == 1); assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { + } + assert(A::count == 0); + assert(B::count == 0); + { std::unique_ptr<A> p(new B); assert(A::count == 1); assert(B::count == 1); @@ -60,7 +40,7 @@ int main() p.reset(new B); assert(A::count == 1); assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); + } + assert(A::count == 0); + assert(B::count == 0); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp index 58b05efa25f61..f838661c53f0e 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/reset_self.pass.cpp @@ -15,15 +15,11 @@ #include <memory> -struct A -{ - std::unique_ptr<A> ptr_; +struct A { + std::unique_ptr<A> ptr_; - A() : ptr_(this) {} - void reset() {ptr_.reset();} + A() : ptr_(this) {} + void reset() { ptr_.reset(); } }; -int main() -{ - (new A)->reset(); -} +int main() { (new A)->reset(); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp new file mode 100644 index 0000000000000..de18865c50aec --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.modifiers/swap.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test swap + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +struct TT { + int state_; + static int count; + TT() : state_(-1) { ++count; } + explicit TT(int i) : state_(i) { ++count; } + TT(const TT& a) : state_(a.state_) { ++count; } + TT& operator=(const TT& a) { + state_ = a.state_; + return *this; + } + ~TT() { --count; } + + friend bool operator==(const TT& x, const TT& y) { + return x.state_ == y.state_; + } +}; + +int TT::count = 0; + +template <class T> +typename std::remove_all_extents<T>::type* newValueInit(int size, + int new_value) { + typedef typename std::remove_all_extents<T>::type VT; + VT* p = newValue<T>(size); + for (int i = 0; i < size; ++i) + (p + i)->state_ = new_value; + return p; +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, TT[], TT>::type VT; + const int expect_alive = IsArray ? 5 : 1; +#if TEST_STD_VER >= 11 + { + using U = std::unique_ptr<VT, Deleter<VT> >; + U u; ((void)u); + ASSERT_NOEXCEPT(u.swap(u)); + } +#endif + { + TT* p1 = newValueInit<VT>(expect_alive, 1); + std::unique_ptr<VT, Deleter<VT> > s1(p1, Deleter<VT>(1)); + TT* p2 = newValueInit<VT>(expect_alive, 2); + std::unique_ptr<VT, Deleter<VT> > s2(p2, Deleter<VT>(2)); + assert(s1.get() == p1); + assert(*s1.get() == TT(1)); + assert(s1.get_deleter().state() == 1); + assert(s2.get() == p2); + assert(*s2.get() == TT(2)); + assert(s2.get_deleter().state() == 2); + s1.swap(s2); + assert(s1.get() == p2); + assert(*s1.get() == TT(2)); + assert(s1.get_deleter().state() == 2); + assert(s2.get() == p1); + assert(*s2.get() == TT(1)); + assert(s2.get_deleter().state() == 1); + assert(TT::count == (expect_alive * 2)); + } + assert(TT::count == 0); +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp index d5c7445b0d86f..b05fb71cdc677 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp @@ -16,24 +16,9 @@ #include <memory> #include <cassert> -int main() -{ - { - std::unique_ptr<int> p(new int(3)); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr<int> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } +int main() { + std::unique_ptr<int[]> p(new int(3)); + const std::unique_ptr<int[]>& cp = p; + (void)(*p); // expected-error {{indirection requires pointer operand ('std::unique_ptr<int []>' invalid)}} + (void)(*cp); // expected-error {{indirection requires pointer operand ('const std::unique_ptr<int []>' invalid)}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp index 9d0cfcaaf353d..b2d3da48daee5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp @@ -16,8 +16,7 @@ #include <memory> #include <cassert> -int main() -{ - std::unique_ptr<int> p(new int(3)); - assert(*p == 3); +int main() { + std::unique_ptr<int> p(new int(3)); + assert(*p == 3); } diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp new file mode 100644 index 0000000000000..9a6d6c65fa810 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/explicit_bool.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test op*() + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <class UPtr> +void doTest(UPtr& p, bool ExpectTrue) { + if (p) + assert(ExpectTrue); + else + assert(!ExpectTrue); + + if (!p) + assert(!ExpectTrue); + else + assert(ExpectTrue); +} + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + typedef std::unique_ptr<VT> U; + { + static_assert((std::is_constructible<bool, U>::value), ""); + static_assert((std::is_constructible<bool, U const&>::value), ""); + } +#if TEST_STD_VER >= 11 + { + static_assert(!std::is_convertible<U, bool>::value, ""); + static_assert(!std::is_convertible<U const&, bool>::value, ""); + } +#endif + { + U p(newValue<VT>(1)); + U const& cp = p; + doTest(p, true); + doTest(cp, true); + } + { + U p; + const U& cp = p; + doTest(p, false); + doTest(cp, false); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp new file mode 100644 index 0000000000000..518e31cf94872 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test get + +#include <memory> +#include <cassert> + +#include "test_macros.h" +#include "unique_ptr_test_helper.h" + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + typedef const VT CVT; + { + typedef std::unique_ptr<VT> U; + int* p = newValue<VT>(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), int*); + ASSERT_SAME_TYPE(decltype(sc.get()), int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } + { + typedef std::unique_ptr<CVT> U; + const int* p = newValue<VT>(1); + U s(p); + U const& sc = s; + ASSERT_SAME_TYPE(decltype(s.get()), const int*); + ASSERT_SAME_TYPE(decltype(sc.get()), const int*); + assert(s.get() == p); + assert(sc.get() == s.get()); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp new file mode 100644 index 0000000000000..6a00d14a2cae4 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/get_deleter.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test get_deleter() + +#include <memory> +#include <cassert> +#include "test_macros.h" + +struct Deleter { + Deleter() {} + + void operator()(void*) const {} + + int test() { return 5; } + int test() const { return 6; } +}; + +template <bool IsArray> +void test_basic() { + typedef typename std::conditional<IsArray, int[], int>::type VT; + { + std::unique_ptr<int, Deleter> p; + assert(p.get_deleter().test() == 5); + } + { + const std::unique_ptr<VT, Deleter> p; + assert(p.get_deleter().test() == 6); + } + { + typedef std::unique_ptr<VT, const Deleter&> UPtr; + const Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), const Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), const Deleter&); + assert(p.get_deleter().test() == 6); + assert(cp.get_deleter().test() == 6); + } + { + typedef std::unique_ptr<VT, Deleter&> UPtr; + Deleter d; + UPtr p(nullptr, d); + const UPtr& cp = p; + ASSERT_SAME_TYPE(decltype(p.get_deleter()), Deleter&); + ASSERT_SAME_TYPE(decltype(cp.get_deleter()), Deleter&); + assert(p.get_deleter().test() == 5); + assert(cp.get_deleter().test() == 5); + } +} + +int main() { + test_basic</*IsArray*/ false>(); + test_basic<true>(); +} diff --git a/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp new file mode 100644 index 0000000000000..d66af054ce649 --- /dev/null +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.runtime.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// unique_ptr + +// test op->() + +#include <memory> +#include <cassert> + +struct V { + int member; +}; + +int main() { + std::unique_ptr<V[]> p; + std::unique_ptr<V[]> const& cp = p; + + p->member; // expected-error {{member reference type 'std::unique_ptr<V []>' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} + + cp->member; // expected-error {{member reference type 'const std::unique_ptr<V []>' is not a pointer}} + // expected-error@-1 {{no member named 'member'}} +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp index 47de8f66ed2e4..8bed9dda2ead3 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_arrow.single.pass.cpp @@ -16,15 +16,13 @@ #include <memory> #include <cassert> -struct A -{ - int i_; +struct A { + int i_; - A() : i_(7) {} + A() : i_(7) {} }; -int main() -{ - std::unique_ptr<A> p(new A); - assert(p->i_ == 7); +int main() { + std::unique_ptr<A> p(new A); + assert(p->i_ == 7); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp index 21e829cbc4442..b47c35afb4f58 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp @@ -16,32 +16,33 @@ #include <memory> #include <cassert> -class A -{ - int state_; - static int next_; +class A { + int state_; + static int next_; + public: - A() : state_(++next_) {} - int get() const {return state_;} + A() : state_(++next_) {} + int get() const { return state_; } - friend bool operator==(const A& x, int y) - {return x.state_ == y;} + friend bool operator==(const A& x, int y) { return x.state_ == y; } - A& operator=(int i) {state_ = i; return *this;} + A& operator=(int i) { + state_ = i; + return *this; + } }; int A::next_ = 0; -int main() -{ - std::unique_ptr<A> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); +int main() { + std::unique_ptr<A[]> p(new A[3]); + assert(p[0] == 1); + assert(p[1] == 2); + assert(p[2] == 3); + p[0] = 3; + p[1] = 2; + p[2] = 1; + assert(p[0] == 3); + assert(p[1] == 2); + assert(p[2] == 1); } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp index 2ae0659adc260..529749da67e99 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.single.fail.cpp @@ -11,14 +11,14 @@ // unique_ptr -// test get +// test op[](size_t) #include <memory> #include <cassert> -int main() -{ - int* p = new int[3]; - std::unique_ptr<int[]> s(p); - assert(s.get() == p); +int main() { + std::unique_ptr<int> p(new int[3]); + std::unique_ptr<int> const& cp = p; + p[0]; // expected-error {{type 'std::unique_ptr<int>' does not provide a subscript operator}} + cp[1]; // expected-error {{type 'const std::unique_ptr<int>' does not provide a subscript operator}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp index 30b4ecb94e18f..30b4ecb94e18f 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp index 00987919413bb..00987919413bb 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp index cc94e9ab3aaab..cc94e9ab3aaab 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp index cfdc2e1d886b0..cfdc2e1d886b0 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp index 07aa659bd9b02..07aa659bd9b02 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp index ace2e4fc71370..ace2e4fc71370 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp index b58f5c55b643a..b58f5c55b643a 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp index 9bf794caeda27..9bf794caeda27 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp index f686e9f01f113..f686e9f01f113 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp index 255e5cd39c69b..255e5cd39c69b 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp index 5d1cf1ff4981e..5d1cf1ff4981e 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp index 41209d977b71e..41209d977b71e 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp index 2949d6310c598..2949d6310c598 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp index 7a409766412fd..7a409766412fd 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp index 528b10e9085d6..528b10e9085d6 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp index b58f5c55b643a..b58f5c55b643a 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp index 22ae217a61d64..22ae217a61d64 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp index 37886548e7212..88a1e04ba4ec5 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/eq.pass.cpp @@ -22,7 +22,7 @@ #include <memory> #include <cassert> -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp index 80653cf707c3e..94ae89ba92b39 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/rel.pass.cpp @@ -30,7 +30,7 @@ #include <memory> #include <cassert> -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp index c525137d48417..7ac0ba490e970 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp +++ b/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/swap.pass.cpp @@ -17,7 +17,7 @@ #include <cassert> #include "test_macros.h" -#include "../deleter.h" +#include "deleter_types.h" struct A { diff --git a/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp index bc65078911b2c..8eab082cf676e 100644 --- a/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp @@ -30,6 +30,8 @@ test() typedef std::hash<T> H; static_assert((std::is_same<typename H::argument_type, T>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(T())); + H h; T bs(static_cast<unsigned long long>(N)); const std::size_t result = h(bs); diff --git a/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp b/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp new file mode 100644 index 0000000000000..1d8bff41ae531 --- /dev/null +++ b/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <bitset> + +// Test that <bitset> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <bitset> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::bitset<0> >(); + test_hash_enabled_for_type<std::bitset<1> >(); + test_hash_enabled_for_type<std::bitset<1024> >(); + test_hash_enabled_for_type<std::bitset<100000> >(); + } +} diff --git a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp index 5387b733918fe..de1cddb5b1ae8 100644 --- a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp @@ -10,6 +10,7 @@ // test bool all() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_all() assert(v.all() == (N == 0)); v.set(); assert(v.all() == true); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.all() == false); diff --git a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp index aa6384a49df1d..7ee83dd074822 100644 --- a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp @@ -10,6 +10,7 @@ // test bool any() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_any() assert(v.any() == false); v.set(); assert(v.any() == (N != 0)); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.any() == true); diff --git a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp index 02e58a7890c54..f352475fc1996 100644 --- a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp @@ -10,6 +10,7 @@ // test bitset<N>::reference operator[](size_t pos); #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -31,7 +32,8 @@ template <std::size_t N> void test_index_const() { std::bitset<N> v1 = make_bitset<N>(); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { assert(v1[N/2] == v1.test(N/2)); typename std::bitset<N>::reference r = v1[N/2]; diff --git a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp index 870a504c2d751..fbde54859f19e 100644 --- a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp @@ -10,6 +10,7 @@ // test constexpr bool operator[](size_t pos) const; #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -31,7 +32,8 @@ template <std::size_t N> void test_index_const() { const std::bitset<N> v1 = make_bitset<N>(); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { assert(v1[N/2] == v1.test(N/2)); } diff --git a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp index b65c636f3c560..1358eaa62d593 100644 --- a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp @@ -10,6 +10,7 @@ // test bool none() const; #include <bitset> +#include <type_traits> #include <cassert> template <std::size_t N> @@ -20,7 +21,8 @@ void test_none() assert(v.none() == true); v.set(); assert(v.none() == (N == 0)); - if (N > 1) + const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings + if (greater_than_1) { v[N/2] = false; assert(v.none() == false); diff --git a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp index 24761c628c03e..5b7e10d677ee3 100644 --- a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp @@ -13,6 +13,7 @@ // bool operator!=(const bitset<N>& rhs) const; #include <bitset> +#include <type_traits> #include <cstdlib> #include <cassert> @@ -36,7 +37,8 @@ void test_equality() const std::bitset<N> v1 = make_bitset<N>(); std::bitset<N> v2 = v1; assert(v1 == v2); - if (N > 0) + const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings + if (greater_than_0) { v2[N/2].flip(); assert(v1 != v2); diff --git a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp index 27d8480d10cfe..a2c9df6b4a22e 100644 --- a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp @@ -11,6 +11,7 @@ #include <bitset> #include <algorithm> +#include <type_traits> #include <climits> #include <cassert> @@ -18,8 +19,9 @@ template <std::size_t N> void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; - const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; - const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X; + const bool is_M_zero = std::integral_constant<bool, M == 0>::value; // avoid compiler warnings + const std::size_t X = is_M_zero ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; + const unsigned long long max = is_M_zero ? 0 : (unsigned long long)(-1) >> X; unsigned long long tests[] = {0, std::min<unsigned long long>(1, max), std::min<unsigned long long>(2, max), diff --git a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp index 3ad1abade9f48..7cabd06e5f322 100644 --- a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp @@ -11,6 +11,7 @@ #include <bitset> #include <algorithm> +#include <type_traits> #include <limits> #include <climits> #include <cassert> @@ -19,8 +20,9 @@ template <std::size_t N> void test_to_ulong() { const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N; - const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; - const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X; + const bool is_M_zero = std::integral_constant<bool, M == 0>::value; // avoid compiler warnings + const std::size_t X = is_M_zero ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; + const std::size_t max = is_M_zero ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X; std::size_t tests[] = {0, std::min<std::size_t>(1, max), std::min<std::size_t>(2, max), diff --git a/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp index b6b3aeea94f85..bf2a2e5891379 100644 --- a/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // Due to C++17 inline variables ASAN flags this test as containing an ODR // violation because Clock::is_steady is defined in both the dylib and this TU. diff --git a/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp index 6302ce6efb34b..b836c0dc00e6d 100644 --- a/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // UNSUPPORTED: libcpp-has-no-monotonic-clock // Due to C++17 inline variables ASAN flags this test as containing an ODR diff --git a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp index cfbe9bd570329..a4058e5ab97b2 100644 --- a/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp +++ b/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp @@ -9,8 +9,8 @@ // // This test uses new symbols that were not defined in the libc++ shipped on // darwin11 and darwin12: -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // Due to C++17 inline variables ASAN flags this test as containing an ODR // violation because Clock::is_steady is defined in both the dylib and this TU. diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp index c0f10147ee893..b85f039526a4b 100644 --- a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp +++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp @@ -11,11 +11,13 @@ // duration -// duration operator+() const; +// constexpr common_type_t<duration> operator+() const; #include <chrono> #include <cassert> +#include <test_macros.h> + int main() { { @@ -23,11 +25,22 @@ int main() std::chrono::minutes m2 = +m; assert(m.count() == m2.count()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { constexpr std::chrono::minutes m(3); constexpr std::chrono::minutes m2 = +m; static_assert(m.count() == m2.count(), ""); } #endif + +// P0548 + { + typedef std::chrono::duration<int, std::ratio<10,10> > D10; + typedef std::chrono::duration<int, std::ratio< 1, 1> > D1; + D10 zero(0); + D10 one(1); + static_assert( (std::is_same< decltype(+one), decltype(zero-one) >::value), ""); + static_assert( (std::is_same< decltype(zero+one), D1>::value), ""); + static_assert( (std::is_same< decltype(+one), D1>::value), ""); + } } diff --git a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp index 00da6f69ca530..347cc1980e819 100644 --- a/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp +++ b/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp @@ -11,11 +11,13 @@ // duration -// duration operator-() const; +// constexpr common_type_t<duration> operator-() const; #include <chrono> #include <cassert> +#include <test_macros.h> + int main() { { @@ -23,11 +25,23 @@ int main() std::chrono::minutes m2 = -m; assert(m2.count() == -m.count()); } -#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if TEST_STD_VER >= 11 { constexpr std::chrono::minutes m(3); constexpr std::chrono::minutes m2 = -m; static_assert(m2.count() == -m.count(), ""); } #endif + +// P0548 + { + typedef std::chrono::duration<int, std::ratio<10,10> > D10; + typedef std::chrono::duration<int, std::ratio< 1, 1> > D1; + D10 zero(0); + D10 one(1); + static_assert( (std::is_same< decltype(-one), decltype(zero-one) >::value), ""); + static_assert( (std::is_same< decltype(zero-one), D1>::value), ""); + static_assert( (std::is_same< decltype(-one), D1>::value), ""); + static_assert( (std::is_same< decltype(+one), D1>::value), ""); + } } diff --git a/test/std/utilities/tuple/tuple.general/ignore.pass.cpp b/test/std/utilities/tuple/tuple.general/ignore.pass.cpp new file mode 100644 index 0000000000000..8dae3a5dcb0e9 --- /dev/null +++ b/test/std/utilities/tuple/tuple.general/ignore.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <tuple> + +// constexpr unspecified ignore; + +// UNSUPPORTED: c++98, c++03 + +#include <tuple> +#include <cassert> + +#include "test_macros.h" + +constexpr bool test_ignore_constexpr() +{ +#if TEST_STD_VER > 11 + { // Test that std::ignore provides constexpr converting assignment. + auto& res = (std::ignore = 42); + assert(&res == &std::ignore); + } + { // Test that std::ignore provides constexpr copy/move constructors + auto copy = std::ignore; + auto moved = std::move(copy); + ((void)moved); + } + { // Test that std::ignore provides constexpr copy/move assignment + auto copy = std::ignore; + copy = std::ignore; + auto moved = std::ignore; + moved = std::move(copy); + } +#endif + return true; +} + +int main() { + { + constexpr auto& ignore_v = std::ignore; + ((void)ignore_v); + } + { + static_assert(test_ignore_constexpr(), ""); + } +#if defined(_LIBCPP_VERSION) + { + static_assert(std::is_trivial<decltype(std::ignore)>::value, ""); + } +#endif +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp index eee1dd88253c9..bd91ce61b4ec8 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp @@ -66,7 +66,7 @@ constexpr bool do_constexpr_test(Tuple&& tup) { return std::make_from_tuple<Tp>(std::forward<Tuple>(tup)).args == tup; } -// Needed by do_forwarding_test() since it compare pairs of different types. +// Needed by do_forwarding_test() since it compares pairs of different types. template <class T1, class T2, class U1, class U2> inline bool operator==(const std::pair<T1, T2>& lhs, const std::pair<U1, U2>& rhs) { return lhs.first == rhs.first && lhs.second == rhs.second; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp index 4ddfb463385c7..0d3b7ff24edb1 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp @@ -89,7 +89,7 @@ int main() // when both #1 and #2 participate in partial ordering #2 will always // be chosen over #1. // See PR22806 and LWG issue #2549 for more information. - // (https://llvm.org/bugs/show_bug.cgi?id=22806) + // (https://bugs.llvm.org/show_bug.cgi?id=22806) using T = std::tuple<int>; std::allocator<int> A; { // rvalue reference @@ -144,8 +144,8 @@ int main() assert(&std::get<0>(t2) == &t1); } // Test constructing a 1-tuple of the form tuple<UDT> from another 1-tuple - // 'tuple<T>' where UDT *can* be constructed from 'tuple<T>' In this case - // the 'tuple(UTypes...)' ctor should be choosen and 'UDT' constructed frow + // 'tuple<T>' where UDT *can* be constructed from 'tuple<T>'. In this case + // the 'tuple(UTypes...)' ctor should be chosen and 'UDT' constructed from // 'tuple<T>'. { using VT = ConstructibleFromTupleAndInt; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp index 4da5fc7f83979..b262f3cacecf7 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp @@ -18,7 +18,7 @@ // NOTE: this constructor does not currently support tags derived from // allocator_arg_t because libc++ has to deduce the parameter as a template -// argument. See PR27684 (https://llvm.org/bugs/show_bug.cgi?id=27684) +// argument. See PR27684 (https://bugs.llvm.org/show_bug.cgi?id=27684) #include <tuple> #include <cassert> @@ -96,7 +96,7 @@ int main() } { // Test that the uses-allocator default constructor does not evaluate - // it's SFINAE when it otherwise shouldn't be selected. Do this by + // its SFINAE when it otherwise shouldn't be selected. Do this by // using 'NonDefaultConstructible' which will cause a compile error // if std::is_default_constructible is evaluated on it. using T = NonDefaultConstructible<>; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp index d282c9c68a42d..eeaa8a24ee68c 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp @@ -100,8 +100,8 @@ int main() assert(std::get<1>(t) == nullptr); } { - // Check that the SFINAE on the default constructor is not evaluted when - // it isn't needed. If the default constructor is evaluted then this test + // Check that the SFINAE on the default constructor is not evaluated when + // it isn't needed. If the default constructor is evaluated then this test // should fail to compile. IllFormedDefault v(0); std::tuple<IllFormedDefault> t(v); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp index c4c3c242d8f82..5dc98afe66106 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp @@ -22,6 +22,24 @@ #include "test_macros.h" +#if TEST_STD_VER > 11 +constexpr bool test_tie_constexpr() { + { + int i = 42; + double f = 1.1; + using ExpectT = std::tuple<int&, decltype(std::ignore)&, double&>; + auto res = std::tie(i, std::ignore, f); + static_assert(std::is_same<ExpectT, decltype(res)>::value, ""); + assert(&std::get<0>(res) == &i); + assert(&std::get<1>(res) == &std::ignore); + assert(&std::get<2>(res) == &f); + // FIXME: If/when tuple gets constexpr assignment + //res = std::make_tuple(101, nullptr, -1.0); + } + return true; +} +#endif + int main() { { @@ -39,5 +57,8 @@ int main() static_assert ( std::get<0>(t) == 42, "" ); static_assert ( std::get<1>(t) == 1.1, "" ); } + { + static_assert(test_tie_constexpr(), ""); + } #endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp index 82b84948f3f0d..26bada38fdd55 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp +++ b/test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp @@ -7,24 +7,17 @@ // //===----------------------------------------------------------------------===// -// <memory> +// UNSUPPORTED: c++98, c++03 -// unique_ptr +// <typeindex> -// Test unique_ptr default ctor +// Test that <typeindex> provides all of the arithmetic, enum, and pointer +// hash specializations. -// default unique_ptr ctor should require non-reference Deleter ctor +#include <typeindex> -#include <memory> +#include "poisoned_hash_helper.hpp" -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter&> p; +int main() { + test_library_hash_specializations_available(); } diff --git a/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp index 6d353f1d30574..9ab58ea6c3aa6 100644 --- a/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp +++ b/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp @@ -18,9 +18,21 @@ #include <typeindex> #include <type_traits> +#include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "poisoned_hash_helper.hpp" +#endif + int main() { + { typedef std::hash<std::type_index> H; static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + } +#if TEST_STD_VER >= 11 + { + test_hash_enabled_for_type<std::type_index>(std::type_index(typeid(int))); + } +#endif } diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp index 2623b800fff7b..cf1afff90cdae 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// REQUIRES-ANY: c++98, c++03 +// REQUIRES: c++98 || c++03 // <utility> diff --git a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp index 8f9fc669251a5..d5e1e232f86f6 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp @@ -32,7 +32,7 @@ struct DeletedDefault { // A class with a deleted default constructor. Used to test the SFINAE - // on std::pairs default constructor. + // on std::pair's default constructor. constexpr explicit DeletedDefault(int x) : value(x) {} constexpr DeletedDefault() = delete; int value; diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp index ace00a16f21e0..af91abe74e1ee 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -15,7 +15,7 @@ // This test doesn't pass due to a constexpr bug in GCC 4.9 that fails // to initialize any type without a user provided constructor in a constant -// expression (ie float). +// expression (e.g. float). // XFAIL: gcc-4.9 // NOTE: The SFINAE on the default constructor is tested in @@ -49,7 +49,7 @@ int main() using P = std::pair<int, NoDefault>; static_assert(!std::is_default_constructible<P>::value, ""); using P2 = std::pair<NoDefault, int>; - static_assert(!std::is_default_constructible<P>::value, ""); + static_assert(!std::is_default_constructible<P2>::value, ""); } #endif } diff --git a/test/std/utilities/variant/variant.get/get_index.pass.cpp b/test/std/utilities/variant/variant.get/get_index.pass.cpp index 72d17b0ed971a..bc7a566040eb1 100644 --- a/test/std/utilities/variant/variant.get/get_index.pass.cpp +++ b/test/std/utilities/variant/variant.get/get_index.pass.cpp @@ -36,7 +36,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<0>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); @@ -52,7 +52,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42l); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<1>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); diff --git a/test/std/utilities/variant/variant.get/get_type.pass.cpp b/test/std/utilities/variant/variant.get/get_type.pass.cpp index fc355378a21a3..013a081f5c770 100644 --- a/test/std/utilities/variant/variant.get/get_type.pass.cpp +++ b/test/std/utilities/variant/variant.get/get_type.pass.cpp @@ -30,7 +30,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<int>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); @@ -46,7 +46,7 @@ void test_const_lvalue_get() { { using V = std::variant<int, const long>; constexpr V v(42l); -#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481 +#ifndef __clang__ // Avoid https://bugs.llvm.org/show_bug.cgi?id=15481 ASSERT_NOEXCEPT(std::get<const long>(v)); #endif ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &); diff --git a/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp b/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp new file mode 100644 index 0000000000000..826dcbae6b9f4 --- /dev/null +++ b/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14 + +// <variant> + +// Test that <variant> provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include <variant> + +#include "poisoned_hash_helper.hpp" + +int main() { + test_library_hash_specializations_available(); +} diff --git a/test/std/utilities/variant/variant.hash/hash.pass.cpp b/test/std/utilities/variant/variant.hash/hash.pass.cpp index d807a7c7e2eaf..2ad2184f4db11 100644 --- a/test/std/utilities/variant/variant.hash/hash.pass.cpp +++ b/test/std/utilities/variant/variant.hash/hash.pass.cpp @@ -21,6 +21,7 @@ #include "test_macros.h" #include "variant_test_helpers.hpp" +#include "poisoned_hash_helper.hpp" #ifndef TEST_HAS_NO_EXCEPTIONS namespace std { @@ -101,8 +102,12 @@ void test_hash_monostate() { assert(h(m1) == h(m2)); { ASSERT_SAME_TYPE(decltype(h(m1)), std::size_t); + ASSERT_NOEXCEPT(h(m1)); static_assert(std::is_copy_constructible<H>::value, ""); } + { + test_hash_enabled_for_type<std::monostate>(); + } } void test_hash_variant_duplicate_elements() { @@ -117,8 +122,38 @@ void test_hash_variant_duplicate_elements() { LIBCPP_ASSERT(h(v1) != h(v2)); } +struct A {}; +struct B {}; + +namespace std { + +template <> +struct hash<B> { + size_t operator()(B const&) const { + return 0; + } +}; + +} + +void test_hash_variant_enabled() { + { + test_hash_enabled_for_type<std::variant<int> >(); + test_hash_enabled_for_type<std::variant<int*, long, double, const int> >(); + } + { + test_hash_disabled_for_type<std::variant<int, A>>(); + test_hash_disabled_for_type<std::variant<const A, void*>>(); + } + { + test_hash_enabled_for_type<std::variant<int, B>>(); + test_hash_enabled_for_type<std::variant<const B, int>>(); + } +} + int main() { test_hash_variant(); test_hash_variant_duplicate_elements(); test_hash_monostate(); + test_hash_variant_enabled(); } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp index 8f694cfd5eda6..0d0b978e3959d 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp @@ -14,7 +14,8 @@ // template <class ...Types> class variant; -// template <size_t I, class ...Args> void emplace(Args&&... args); +// template <size_t I, class ...Args> +// variant_alternative_t<I, variant<Types...>>& emplace(Args&&... args); #include <cassert> #include <string> @@ -85,10 +86,14 @@ void test_basic() { { using V = std::variant<int>; V v(42); - v.emplace<0>(); + auto& ref1 = v.emplace<0>(); + static_assert(std::is_same_v<int&, decltype(ref1)>, ""); assert(std::get<0>(v) == 0); - v.emplace<0>(42); + assert(&ref1 == &std::get<0>(v)); + auto& ref2 = v.emplace<0>(42); + static_assert(std::is_same_v<int&, decltype(ref2)>, ""); assert(std::get<0>(v) == 42); + assert(&ref2 == &std::get<0>(v)); } { using V = @@ -96,13 +101,19 @@ void test_basic() { const int x = 100; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<1>(); + auto& ref1 = v.emplace<1>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); - v.emplace<2>(&x); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<2>(&x); + static_assert(std::is_same_v<const void*&, decltype(ref2)>, ""); assert(std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace with multiple args - v.emplace<4>(3, 'a'); + auto& ref3 = v.emplace<4>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref3)>, ""); assert(std::get<4>(v) == "aaa"); + assert(&ref3 == &std::get<4>(v)); } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { @@ -113,20 +124,30 @@ void test_basic() { int z = 43; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<1>(); + auto& ref1 = v.emplace<1>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); + assert(&ref1 == &std::get<1>(v)); // emplace a reference - v.emplace<2>(x); + auto& ref2 = v.emplace<2>(x); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace an rvalue reference - v.emplace<3>(std::move(y)); + auto& ref3 = v.emplace<3>(std::move(y)); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<3>(v) == &y); + assert(&ref3 == &std::get<3>(v)); // re-emplace a new reference over the active member - v.emplace<3>(std::move(z)); + auto& ref4 = v.emplace<3>(std::move(z)); + static_assert(std::is_same_v<&, decltype(ref)>, ""); assert(&std::get<3>(v) == &z); + assert(&ref4 == &std::get<3>(v)); // emplace with multiple args - v.emplace<5>(3, 'a'); + auto& ref5 = v.emplace<5>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref5)>, ""); assert(std::get<5>(v) == "aaa"); + assert(&ref5 == &std::get<5>(v)); } #endif } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp index f466b160cb4f2..e69988a08e963 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_init_list_args.pass.cpp @@ -15,7 +15,7 @@ // template <class ...Types> class variant; // template <size_t I, class U, class ...Args> -// void emplace(initializer_list<U> il,Args&&... args); +// variant_alternative_t<I, variant<Types...>>& emplace(initializer_list<U> il,Args&&... args); #include <cassert> #include <string> @@ -70,13 +70,19 @@ void test_emplace_sfinae() { void test_basic() { using V = std::variant<int, InitList, InitListArg, TestTypes::NoCtors>; V v; - v.emplace<1>({1, 2, 3}); + auto& ref1 = v.emplace<1>({1, 2, 3}); + static_assert(std::is_same_v<InitList&, decltype(ref1)>, ""); assert(std::get<1>(v).size == 3); - v.emplace<2>({1, 2, 3, 4}, 42); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<2>({1, 2, 3, 4}, 42); + static_assert(std::is_same_v<InitListArg&, decltype(ref2)>, ""); assert(std::get<2>(v).size == 4); assert(std::get<2>(v).value == 42); - v.emplace<1>({1}); + assert(&ref2 == &std::get<2>(v)); + auto& ref3 = v.emplace<1>({1}); + static_assert(std::is_same_v<InitList&, decltype(ref3)>, ""); assert(std::get<1>(v).size == 1); + assert(&ref3 == &std::get<1>(v)); } int main() { diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp index 4ca2cc4803e3d..8e329024b9df6 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp @@ -14,7 +14,7 @@ // template <class ...Types> class variant; -// template <class T, class ...Args> void emplace(Args&&... args); +// template <class T, class ...Args> T& emplace(Args&&... args); #include <cassert> #include <string> @@ -86,10 +86,14 @@ void test_basic() { { using V = std::variant<int>; V v(42); - v.emplace<int>(); + auto& ref1 = v.emplace<int>(); + static_assert(std::is_same_v<int&, decltype(ref1)>, ""); assert(std::get<0>(v) == 0); - v.emplace<int>(42); + assert(&ref1 == &std::get<0>(v)); + auto& ref2 = v.emplace<int>(42); + static_assert(std::is_same_v<int&, decltype(ref2)>, ""); assert(std::get<0>(v) == 42); + assert(&ref2 == &std::get<0>(v)); } { using V = @@ -97,13 +101,19 @@ void test_basic() { const int x = 100; V v(std::in_place_type<int>, -1); // default emplace a value - v.emplace<long>(); + auto& ref1 = v.emplace<long>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<1>(v) == 0); - v.emplace<const void *>(&x); + assert(&ref1 == &std::get<1>(v)); + auto& ref2 = v.emplace<const void *>(&x); + static_assert(std::is_same_v<const void *&, decltype(ref2)>, ""); assert(std::get<2>(v) == &x); + assert(&ref2 == &std::get<2>(v)); // emplace with multiple args - v.emplace<std::string>(3, 'a'); + auto& ref3 = v.emplace<std::string>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref3)>, ""); assert(std::get<4>(v) == "aaa"); + assert(&ref3 == &std::get<4>(v)); } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { @@ -114,20 +124,30 @@ void test_basic() { int z = 43; V v(std::in_place_index<0>, -1); // default emplace a value - v.emplace<long>(); + auto& ref1 = v.emplace<long>(); + static_assert(std::is_same_v<long&, decltype(ref1)>, ""); assert(std::get<long>(v) == 0); + assert(&ref1 == &std::get<long>(v)); // emplace a reference - v.emplace<const int &>(x); + auto& ref2 = v.emplace<const int &>(x); + static_assert(std::is_same_v<const int&, decltype(ref2)>, ""); assert(&std::get<const int &>(v) == &x); + assert(&ref2 == &std::get<const int &>(v)); // emplace an rvalue reference - v.emplace<int &&>(std::move(y)); + auto& ref3 = v.emplace<int &&>(std::move(y)); + static_assert(std::is_same_v<int &&, decltype(ref3)>, ""); assert(&std::get<int &&>(v) == &y); + assert(&ref3 == &std::get<int &&>(v)); // re-emplace a new reference over the active member - v.emplace<int &&>(std::move(z)); + auto& ref4 = v.emplace<int &&>(std::move(z)); + static_assert(std::is_same_v<int &, decltype(ref4)>, ""); assert(&std::get<int &&>(v) == &z); + assert(&ref4 == &std::get<int &&>(v)); // emplace with multiple args - v.emplace<std::string>(3, 'a'); + auto& ref5 = v.emplace<std::string>(3, 'a'); + static_assert(std::is_same_v<std::string&, decltype(ref5)>, ""); assert(std::get<std::string>(v) == "aaa"); + assert(&ref5 == &std::get<std::string>(v)); } #endif } diff --git a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp index b2be8ac5b3fd1..da1658cb88f66 100644 --- a/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_init_list_args.pass.cpp @@ -15,7 +15,7 @@ // template <class ...Types> class variant; // template <class T, class U, class ...Args> -// void emplace(initializer_list<U> il,Args&&... args); +// T& emplace(initializer_list<U> il,Args&&... args); #include <cassert> #include <string> @@ -70,13 +70,19 @@ void test_emplace_sfinae() { void test_basic() { using V = std::variant<int, InitList, InitListArg, TestTypes::NoCtors>; V v; - v.emplace<InitList>({1, 2, 3}); + auto& ref1 = v.emplace<InitList>({1, 2, 3}); + static_assert(std::is_same_v<InitList&,decltype(ref1)>, ""); assert(std::get<InitList>(v).size == 3); - v.emplace<InitListArg>({1, 2, 3, 4}, 42); + assert(&ref1 == &std::get<InitList>(v)); + auto& ref2 = v.emplace<InitListArg>({1, 2, 3, 4}, 42); + static_assert(std::is_same_v<InitListArg&,decltype(ref2)>, ""); assert(std::get<InitListArg>(v).size == 4); assert(std::get<InitListArg>(v).value == 42); - v.emplace<InitList>({1}); + assert(&ref2 == &std::get<InitListArg>(v)); + auto& ref3 = v.emplace<InitList>({1}); + static_assert(std::is_same_v<InitList&,decltype(ref3)>, ""); assert(std::get<InitList>(v).size == 1); + assert(&ref3 == &std::get<InitList>(v)); } int main() { diff --git a/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp b/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp index 6675b5f2b2ba3..8025b9e0774eb 100644 --- a/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp @@ -10,10 +10,13 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// The following compilers don't allow constexpr variables of non-literal type. +// The following compilers don't consider a type an aggregate type (and +// consequently not a literal type) if it has a base class at all. +// In C++17, an aggregate type is allowed to have a base class if it's not +// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors). // XFAIL: gcc-5, gcc-6 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> diff --git a/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp b/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp index a0c57e132403c..660a21c4f31d3 100644 --- a/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp +++ b/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp @@ -10,10 +10,13 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 -// The following compilers don't allow constexpr variables of non-literal type. +// The following compilers don't consider a type an aggregate type (and +// consequently not a literal type) if it has a base class at all. +// In C++17, an aggregate type is allowed to have a base class if it's not +// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors). // XFAIL: gcc-5, gcc-6 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 // <variant> diff --git a/test/support/MoveOnly.h b/test/support/MoveOnly.h index a3e9cca89ee50..0ffb4ffe3b2fe 100644 --- a/test/support/MoveOnly.h +++ b/test/support/MoveOnly.h @@ -41,8 +41,9 @@ namespace std { template <> struct hash<MoveOnly> - : public std::unary_function<MoveOnly, std::size_t> { + typedef MoveOnly argument_type; + typedef size_t result_type; std::size_t operator()(const MoveOnly& x) const {return x.get();} }; diff --git a/test/support/constexpr_char_traits.hpp b/test/support/constexpr_char_traits.hpp index 0a73d3ad1eadd..7508567ca1994 100644 --- a/test/support/constexpr_char_traits.hpp +++ b/test/support/constexpr_char_traits.hpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-------_------------ constexpr_char_traits ---------------------------===// +//===-------------------- constexpr_char_traits ---------------------------===// // // The LLVM Compiler Infrastructure // @@ -12,6 +12,7 @@ #define _CONSTEXPR_CHAR_TRAITS #include <string> +#include <cassert> #include "test_macros.h" @@ -118,7 +119,7 @@ template <class _CharT> TEST_CONSTEXPR_CXX14 _CharT* constexpr_char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + assert(__s2 < __s1 || __s2 >= __s1+__n); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); diff --git a/test/support/container_test_types.h b/test/support/container_test_types.h index c17ce91394844..08e88f0914616 100644 --- a/test/support/container_test_types.h +++ b/test/support/container_test_types.h @@ -33,7 +33,7 @@ // the construction of types using an allocator. This type is used to communicate // between the test author, the containers allocator, and the types // being constructed by the container. -// The controllers primary functions are: +// The controller's primary functions are: // 1. Allow calls to 'a.construct(p, args...)' to be checked by a test. // The test uses 'cc->expect<Args...>()' to specify that the allocator // should expect one call to 'a.construct' with the specified argument @@ -366,7 +366,7 @@ struct CopyInsertable { CopyInsertable(CopyInsertable&& other) : CopyInsertable(other) {} - // Forgive pair for not downcasting this to an lvalue it its constructors. + // Forgive pair for not downcasting this to an lvalue in its constructors. CopyInsertable(CopyInsertable const && other) : CopyInsertable(other) {} diff --git a/test/support/controlled_allocators.hpp b/test/support/controlled_allocators.hpp index 280aaa564c697..f0d615c35fa9f 100644 --- a/test/support/controlled_allocators.hpp +++ b/test/support/controlled_allocators.hpp @@ -26,7 +26,7 @@ struct AllocController; // 'AllocController' is a concrete type that instruments and controls the - // behavior of of test allocators. + // behavior of test allocators. template <class T, size_t ID = 0> class CountingAllocator; diff --git a/test/support/debug_mode_helper.h b/test/support/debug_mode_helper.h index 0c6170589c2ed..350deb08382e9 100644 --- a/test/support/debug_mode_helper.h +++ b/test/support/debug_mode_helper.h @@ -191,8 +191,9 @@ public: static void run_allocator_aware_tests() { try { SwapNonEqualAllocators(); - if constexpr (CT != CT_ForwardList) { - SwapInvalidatesIterators(); // FIXME: This should work + if constexpr (CT != CT_ForwardList ) { + // FIXME: This should work for both forward_list and string + SwapInvalidatesIterators(); } } catch (...) { assert(false && "uncaught debug exception"); @@ -359,7 +360,10 @@ private: iterator it2 = C2.begin(); swap(C1, C2); CHECK_DEBUG_THROWS( C1.erase(it1) ); - C1.erase(it2); + if (CT == CT_String) { + CHECK_DEBUG_THROWS(C1.erase(it2)); + } else + C1.erase(it2); //C2.erase(it1); CHECK_DEBUG_THROWS( C1.erase(it1) ); } diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/support/deleter_types.h index 1d8e19d5bc419..ec7016801235d 100644 --- a/test/std/utilities/memory/unique.ptr/deleter.h +++ b/test/support/deleter_types.h @@ -13,14 +13,15 @@ // Example move-only deleter -#ifndef DELETER_H -#define DELETER_H +#ifndef SUPPORT_DELETER_TYPES_H +#define SUPPORT_DELETER_TYPES_H #include <type_traits> #include <utility> #include <cassert> #include "test_macros.h" +#include "min_allocator.h" #if TEST_STD_VER >= 11 @@ -192,6 +193,10 @@ public: CDeleter() : state_(0) {} explicit CDeleter(int s) : state_(s) {} + template <class U> + CDeleter(const CDeleter<U>& d) + : state_(d.state()) {} + ~CDeleter() {assert(state_ >= 0); state_ = -1;} int state() const {return state_;} @@ -335,4 +340,107 @@ public: }; -#endif // DELETER_H +struct test_deleter_base +{ + static int count; + static int dealloc_count; +}; + +int test_deleter_base::count = 0; +int test_deleter_base::dealloc_count = 0; + +template <class T> +class test_deleter + : public test_deleter_base +{ + int state_; + +public: + + test_deleter() : state_(0) {++count;} + explicit test_deleter(int s) : state_(s) {++count;} + test_deleter(const test_deleter& d) + : state_(d.state_) {++count;} + ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;} +#if TEST_STD_VER >= 11 + test_deleter* operator&() const = delete; +#else +private: + test_deleter* operator&() const; +#endif +}; + +template <class T> +void +swap(test_deleter<T>& x, test_deleter<T>& y) +{ + test_deleter<T> t(std::move(x)); + x = std::move(y); + y = std::move(t); +} + +#if TEST_STD_VER >= 11 + +template <class T, size_t ID = 0> +class PointerDeleter +{ + PointerDeleter(const PointerDeleter&); + PointerDeleter& operator=(const PointerDeleter&); + +public: + typedef min_pointer<T, std::integral_constant<size_t, ID>> pointer; + + PointerDeleter() = default; + PointerDeleter(PointerDeleter&&) = default; + PointerDeleter& operator=(PointerDeleter&&) = default; + explicit PointerDeleter(int) {} + + template <class U> + PointerDeleter(PointerDeleter<U, ID>&&, + typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) + {} + + void operator()(pointer p) { if (p) { delete std::addressof(*p); }} + +private: + template <class U> + PointerDeleter(const PointerDeleter<U, ID>&, + typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); +}; + + +template <class T, size_t ID> +class PointerDeleter<T[], ID> +{ + PointerDeleter(const PointerDeleter&); + PointerDeleter& operator=(const PointerDeleter&); + +public: + typedef min_pointer<T, std::integral_constant<size_t, ID> > pointer; + + PointerDeleter() = default; + PointerDeleter(PointerDeleter&&) = default; + PointerDeleter& operator=(PointerDeleter&&) = default; + explicit PointerDeleter(int) {} + + template <class U> + PointerDeleter(PointerDeleter<U, ID>&&, + typename std::enable_if<!std::is_same<U, T>::value>::type* = 0) + {} + + void operator()(pointer p) { if (p) { delete [] std::addressof(*p); }} + +private: + template <class U> + PointerDeleter(const PointerDeleter<U, ID>&, + typename std::enable_if<!std::is_same<U, T>::value>::type* = 0); +}; + +#endif // TEST_STD_VER >= 11 + +#endif // SUPPORT_DELETER_TYPES_H diff --git a/test/support/demangle.h b/test/support/demangle.h index 2a9757d804541..98d93c85ad7b8 100644 --- a/test/support/demangle.h +++ b/test/support/demangle.h @@ -16,7 +16,7 @@ #if !defined(TEST_HAS_NO_DEMANGLE) # if defined(__GNUC__) || defined(__clang__) -# if __has_include("cxxabi.h") +# if __has_include("cxxabi.h") && !defined(_LIBCPP_ABI_MICROSOFT) # include "cxxabi.h" # else # define TEST_HAS_NO_DEMANGLE @@ -34,9 +34,7 @@ inline std::string demangle(const char* mangled_name) { template <size_t N> struct Printer; inline std::string demangle(const char* mangled_name) { int status = 0; - std::string input(mangled_name); - input.insert(0, "_Z"); - char* out = __cxxabiv1::__cxa_demangle(input.c_str(), nullptr, nullptr, &status); + char* out = __cxxabiv1::__cxa_demangle(mangled_name, nullptr, nullptr, &status); if (out != nullptr) { std::string res(out); std::free(out); diff --git a/test/support/filesystem_dynamic_test_helper.py b/test/support/filesystem_dynamic_test_helper.py index 1f48c95279829..d2b2810d0992d 100644 --- a/test/support/filesystem_dynamic_test_helper.py +++ b/test/support/filesystem_dynamic_test_helper.py @@ -75,7 +75,7 @@ def create_fifo(source): def create_socket(source): - mode = 0600|stat.S_IFSOCK + mode = 0o600 | stat.S_IFSOCK os.mknod(sanitize(source), mode) diff --git a/test/support/filesystem_test_helper.hpp b/test/support/filesystem_test_helper.hpp index c2e41fca09c87..6cc0e370a7868 100644 --- a/test/support/filesystem_test_helper.hpp +++ b/test/support/filesystem_test_helper.hpp @@ -381,7 +381,7 @@ bool checkCollectionsEqualBackwards( } // We often need to test that the error_code was cleared if no error occurs -// this function returns a error_code which is set to an error that will +// this function returns an error_code which is set to an error that will // never be returned by the filesystem functions. inline std::error_code GetTestEC() { return std::make_error_code(std::errc::address_family_not_supported); diff --git a/test/support/min_allocator.h b/test/support/min_allocator.h index d518e4a6d77cb..a3af9e1db66d0 100644 --- a/test/support/min_allocator.h +++ b/test/support/min_allocator.h @@ -136,31 +136,31 @@ public: #include <memory> -template <class T> class min_pointer; -template <class T> class min_pointer<const T>; -template <> class min_pointer<void>; -template <> class min_pointer<const void>; +template <class T, class = std::integral_constant<size_t, 0> > class min_pointer; +template <class T, class ID> class min_pointer<const T, ID>; +template <class ID> class min_pointer<void, ID>; +template <class ID> class min_pointer<const void, ID>; template <class T> class min_allocator; -template <> -class min_pointer<const void> +template <class ID> +class min_pointer<const void, ID> { const void* ptr_; public: min_pointer() TEST_NOEXCEPT = default; min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {} template <class T> - min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {} + min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {} explicit operator bool() const {return ptr_ != nullptr;} friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} - template <class U> friend class min_pointer; + template <class U, class XID> friend class min_pointer; }; -template <> -class min_pointer<void> +template <class ID> +class min_pointer<void, ID> { void* ptr_; public: @@ -172,16 +172,16 @@ public: !std::is_const<T>::value >::type > - min_pointer(min_pointer<T> p) TEST_NOEXCEPT : ptr_(p.ptr_) {} + min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {} explicit operator bool() const {return ptr_ != nullptr;} friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} - template <class U> friend class min_pointer; + template <class U, class XID> friend class min_pointer; }; -template <class T> +template <class T, class ID> class min_pointer { T* ptr_; @@ -190,7 +190,7 @@ class min_pointer public: min_pointer() TEST_NOEXCEPT = default; min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {} - explicit min_pointer(min_pointer<void> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {} + explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {} explicit operator bool() const {return ptr_ != nullptr;} @@ -247,12 +247,12 @@ public: friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} - template <class U> friend class min_pointer; + template <class U, class XID> friend class min_pointer; template <class U> friend class min_allocator; }; -template <class T> -class min_pointer<const T> +template <class T, class ID> +class min_pointer<const T, ID> { const T* ptr_; @@ -260,8 +260,8 @@ class min_pointer<const T> public: min_pointer() TEST_NOEXCEPT = default; min_pointer(std::nullptr_t) : ptr_(nullptr) {} - min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {} - explicit min_pointer(min_pointer<const void> p) : ptr_(static_cast<const T*>(p.ptr_)) {} + min_pointer(min_pointer<T, ID> p) : ptr_(p.ptr_) {} + explicit min_pointer(min_pointer<const void, ID> p) : ptr_(static_cast<const T*>(p.ptr_)) {} explicit operator bool() const {return ptr_ != nullptr;} @@ -318,37 +318,37 @@ public: friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;} friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);} - template <class U> friend class min_pointer; + template <class U, class XID> friend class min_pointer; }; -template <class T> +template <class T, class ID> inline bool -operator==(min_pointer<T> x, std::nullptr_t) +operator==(min_pointer<T, ID> x, std::nullptr_t) { return !static_cast<bool>(x); } -template <class T> +template <class T, class ID> inline bool -operator==(std::nullptr_t, min_pointer<T> x) +operator==(std::nullptr_t, min_pointer<T, ID> x) { return !static_cast<bool>(x); } -template <class T> +template <class T, class ID> inline bool -operator!=(min_pointer<T> x, std::nullptr_t) +operator!=(min_pointer<T, ID> x, std::nullptr_t) { return static_cast<bool>(x); } -template <class T> +template <class T, class ID> inline bool -operator!=(std::nullptr_t, min_pointer<T> x) +operator!=(std::nullptr_t, min_pointer<T, ID> x) { return static_cast<bool>(x); } diff --git a/test/support/msvc_stdlib_force_include.hpp b/test/support/msvc_stdlib_force_include.hpp new file mode 100644 index 0000000000000..660645646d33b --- /dev/null +++ b/test/support/msvc_stdlib_force_include.hpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP +#define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP + +// This header is force-included when running the libc++ tests against the +// MSVC standard library. + +// Silence warnings about CRT machinery. +#define _CRT_SECURE_NO_WARNINGS + +// Avoid assertion dialogs. +#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort() + +#include <crtdbg.h> +#include <stdlib.h> + +#if defined(_LIBCPP_VERSION) + #error This header may not be used when targeting libc++ +#endif + +struct AssertionDialogAvoider { + AssertionDialogAvoider() { + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + } +}; + +const AssertionDialogAvoider assertion_dialog_avoider{}; + +// MSVC frontend only configurations +#if !defined(__clang__) + #define TEST_STD_VER 17 + + // Simulate feature-test macros. + #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X + #define _MSVC_HAS_FEATURE_cxx_exceptions 1 + #define _MSVC_HAS_FEATURE_cxx_rtti 1 + #define _MSVC_HAS_FEATURE_address_sanitizer 0 + #define _MSVC_HAS_FEATURE_memory_sanitizer 0 + #define _MSVC_HAS_FEATURE_thread_sanitizer 0 + + // Silence compiler warnings. + #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored + #pragma warning(disable: 4521) // multiple copy constructors specified + #pragma warning(disable: 4702) // unreachable code + #pragma warning(disable: 6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. + #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations. +#endif // !defined(__clang__) + +// MSVC doesn't have __int128_t. +#define _LIBCPP_HAS_NO_INT128 + +// MSVC has quick_exit() and at_quick_exit(). +#define _LIBCPP_HAS_QUICK_EXIT + +// atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix. +#define _ENABLE_ATOMIC_ALIGNMENT_FIX + +// Enable features that /std:c++latest removes by default. +#define _HAS_AUTO_PTR_ETC 1 +#define _HAS_FUNCTION_ASSIGN 1 +#define _HAS_OLD_IOSTREAMS_MEMBERS 1 + +// Silence warnings about raw pointers and other unchecked iterators. +#define _SCL_SECURE_NO_WARNINGS + +#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_HPP diff --git a/test/support/platform_support.h b/test/support/platform_support.h index f4c2247e0dfbc..737e5d7a01ce5 100644 --- a/test/support/platform_support.h +++ b/test/support/platform_support.h @@ -59,7 +59,7 @@ #endif #if defined(_NEWLIB_VERSION) && defined(__STRICT_ANSI__) -// Newlib provies this, but in the header it's under __STRICT_ANSI__ +// Newlib provides this, but in the header it's under __STRICT_ANSI__ extern "C" { int mkstemp(char*); } diff --git a/test/support/poisoned_hash_helper.hpp b/test/support/poisoned_hash_helper.hpp new file mode 100644 index 0000000000000..824c35837b2b3 --- /dev/null +++ b/test/support/poisoned_hash_helper.hpp @@ -0,0 +1,247 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// +#ifndef SUPPORT_POISONED_HASH_HELPER_HPP +#define SUPPORT_POISONED_HASH_HELPER_HPP + +#include <type_traits> +#include <cassert> + +#include "test_macros.h" +#include "test_workarounds.h" + +#if TEST_STD_VER < 11 +#error this header may only be used in C++11 or newer +#endif + +template <class ...Args> struct TypeList; + +// Test that the specified Hash meets the requirements of an enabled hash +template <class Hash, class Key, class InputKey = Key> +void test_hash_enabled(InputKey const& key = InputKey{}); + +template <class T, class InputKey = T> +void test_hash_enabled_for_type(InputKey const& key = InputKey{}) { + return test_hash_enabled<std::hash<T>, T, InputKey>(key); +} + +// Test that the specified Hash meets the requirements of a disabled hash. +template <class Hash, class Key> +void test_hash_disabled(); + +template <class T> +void test_hash_disabled_for_type() { + return test_hash_disabled<std::hash<T>, T>(); +} + +namespace PoisonedHashDetail { + enum Enum {}; + enum EnumClass : bool {}; + struct Class {}; +} + +// Each header that declares the template hash provides enabled +// specializations of hash for nullptr t and all cv-unqualified +// arithmetic, enumeration, and pointer types. +using LibraryHashTypes = TypeList< +#if !defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR) +#if TEST_STD_VER > 14 + decltype(nullptr), +#endif +#endif + bool, + char, + signed char, + unsigned char, + wchar_t, +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t, + char32_t, +#endif + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, +#ifndef _LIBCPP_HAS_NO_INT128 + __int128_t, + __uint128_t, +#endif + float, + double, + long double, +#if TEST_STD_VER >= 14 + // Enum types + PoisonedHashDetail::Enum, + PoisonedHashDetail::EnumClass, +#endif + // pointer types + void*, + void const*, + PoisonedHashDetail::Class* + >; + + +// Test that each of the library hash specializations for arithmetic types, +// enum types, and pointer types are available and enabled. +template <class Types = LibraryHashTypes> +void test_library_hash_specializations_available(Types = Types{}); + + +namespace PoisonedHashDetail { + +template <class T, class = typename T::foo_bar_baz> +constexpr bool instantiate(int) { return true; } +template <class> constexpr bool instantiate(long) { return true; } +template <class T> constexpr bool instantiate() { return instantiate<T>(0); } + +template <class To> +struct ConvertibleToSimple { + operator To() const { + return To{}; + } +}; + +template <class To> +struct ConvertibleTo { + To to{}; + operator To&() & { return to; } + operator To const&() const & { return to; } + operator To&&() && { return std::move(to); } + operator To const&&() const && { return std::move(to); } +}; + +template <class HashExpr, + class Res = typename std::result_of<HashExpr>::type> +constexpr bool can_hash(int) { + return std::is_same<Res, size_t>::value; +} +template <class> constexpr bool can_hash(long) { return false; } +template <class T> constexpr bool can_hash() { return can_hash<T>(0); } + +} // namespace PoisonedHashDetail + +template <class Hash, class Key, class InputKey> +void test_hash_enabled(InputKey const& key) { + using namespace PoisonedHashDetail; + + static_assert(std::is_destructible<Hash>::value, ""); + // Enabled hash requirements + static_assert(std::is_default_constructible<Hash>::value, ""); + static_assert(std::is_copy_constructible<Hash>::value, ""); + static_assert(std::is_move_constructible<Hash>::value, ""); + static_assert(std::is_copy_assignable<Hash>::value, ""); + static_assert(std::is_move_assignable<Hash>::value, ""); + +#if TEST_STD_VER > 14 + static_assert(std::is_swappable<Hash>::value, ""); +#elif defined(_LIBCPP_VERSION) + static_assert(std::__is_swappable<Hash>::value, ""); +#endif + + // Hashable requirements + using CKey = ConvertibleTo<Key>; + static_assert(can_hash<Hash(Key&)>(), ""); + static_assert(can_hash<Hash(Key const&)>(), ""); + static_assert(can_hash<Hash(Key&&)>(), ""); + static_assert(can_hash<Hash const&(Key&)>(), ""); + static_assert(can_hash<Hash const&(Key const&)>(), ""); + static_assert(can_hash<Hash const&(Key&&)>(), ""); + + static_assert(can_hash<Hash(ConvertibleToSimple<Key>&)>(), ""); + static_assert(can_hash<Hash(ConvertibleToSimple<Key> const&)>(), ""); + static_assert(can_hash<Hash(ConvertibleToSimple<Key>&&)>(), ""); + + static_assert(can_hash<Hash(ConvertibleTo<Key>&)>(), ""); + static_assert(can_hash<Hash(ConvertibleTo<Key> const&)>(), ""); + static_assert(can_hash<Hash(ConvertibleTo<Key> &&)>(), ""); + static_assert(can_hash<Hash(ConvertibleTo<Key> const&&)>(), ""); + + const Hash h{}; + assert(h(key) == h(key)); + +} + +template <class Hash, class Key> +void test_hash_disabled() { + using namespace PoisonedHashDetail; + + // Disabled hash requirements + static_assert(!std::is_default_constructible<Hash>::value, ""); + static_assert(!std::is_copy_constructible<Hash>::value, ""); + static_assert(!std::is_move_constructible<Hash>::value, ""); + static_assert(!std::is_copy_assignable<Hash>::value, ""); + static_assert(!std::is_move_assignable<Hash>::value, ""); + + static_assert(!std::is_function< + typename std::remove_pointer< + typename std::remove_reference<Hash>::type + >::type + >::value, ""); + + // Hashable requirements + using CKey = ConvertibleTo<Key>; + static_assert(!can_hash<Hash(Key&)>(), ""); + static_assert(!can_hash<Hash(Key const&)>(), ""); + static_assert(!can_hash<Hash(Key&&)>(), ""); + static_assert(!can_hash<Hash const&(Key&)>(), ""); + static_assert(!can_hash<Hash const&(Key const&)>(), ""); + static_assert(!can_hash<Hash const&(Key&&)>(), ""); + + static_assert(!can_hash<Hash(ConvertibleToSimple<Key>&)>(), ""); + static_assert(!can_hash<Hash(ConvertibleToSimple<Key> const&)>(), ""); + static_assert(!can_hash<Hash(ConvertibleToSimple<Key>&&)>(), ""); + + static_assert(!can_hash<Hash(ConvertibleTo<Key>&)>(), ""); + static_assert(!can_hash<Hash(ConvertibleTo<Key> const&)>(), ""); + static_assert(!can_hash<Hash(ConvertibleTo<Key> &&)>(), ""); + static_assert(!can_hash<Hash(ConvertibleTo<Key> const&&)>(), ""); +} + + +template <class First, class ...Rest> +struct TypeList<First, Rest...> { + template <template <class> class Trait, bool Expect = true> + static constexpr bool assertTrait() { + static_assert(Trait<First>::value == Expect, ""); + return TypeList<Rest...>::template assertTrait<Trait, Expect>(); + } + + template <class Trait> + static void applyTrait() { + Trait::template apply<First>(); + TypeList<Rest...>::template applyTrait<Trait>(); + } +}; + +template <> +struct TypeList<> { + template <template <class> class Trait, bool Expect = true> + static constexpr bool assertTrait() { + return true; + } + template <class Trait> + static void applyTrait() {} +}; + + +struct TestLibraryTrait { + template <class Type> + static void apply() { test_hash_enabled<std::hash<Type>, Type>(); } +}; + +template <class Types> +void test_library_hash_specializations_available(Types) { + Types::template applyTrait<TestLibraryTrait >(); +} + +#endif // SUPPORT_POISONED_HASH_HELPER_HPP diff --git a/test/support/set_windows_crt_report_mode.h b/test/support/set_windows_crt_report_mode.h new file mode 100644 index 0000000000000..5fc1698b4073c --- /dev/null +++ b/test/support/set_windows_crt_report_mode.h @@ -0,0 +1,36 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// +#ifndef SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H +#define SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H + +#ifndef _DEBUG +#error _DEBUG must be defined when using this header +#endif + +#ifndef _WIN32 +#error This header can only be used when targeting Windows +#endif + +#include <crtdbg.h> + +// On Windows in debug builds the default assertion handler opens a new dialog +// window which must be dismissed manually by the user. This function overrides +// that setting and instead changes the assertion handler to log to stderr +// instead. +inline int init_crt_report_mode() { + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); + return 0; +} + +static int init_crt_anchor = init_crt_report_mode(); + +#endif // SUPPORT_SET_WINDOWS_CRT_REPORT_MODE_H diff --git a/test/support/test.support/test_demangle.pass.cpp b/test/support/test.support/test_demangle.pass.cpp index c924246e8c0b2..08808c1942ccd 100644 --- a/test/support/test.support/test_demangle.pass.cpp +++ b/test/support/test.support/test_demangle.pass.cpp @@ -20,7 +20,7 @@ int main() { const char* raw; const char* expect; } TestCases[] = { - {typeid(int).name(), "i"}, // FIXME + {typeid(int).name(), "int"}, {typeid(MyType).name(), "MyType"}, {typeid(ArgumentListID<int, MyType>).name(), "ArgumentListID<int, MyType>"} }; diff --git a/test/support/test.support/test_poisoned_hash_helper.pass.cpp b/test/support/test.support/test_poisoned_hash_helper.pass.cpp new file mode 100644 index 0000000000000..4dffae6dbdfe7 --- /dev/null +++ b/test/support/test.support/test_poisoned_hash_helper.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Test that the header `poisoned_hash_helper.hpp` doesn't include any +// headers that provide hash<T> specializations. This is required so that the +// 'test_library_hash_specializations_available()' function returns false +// by default, unless a STL header providing hash has already been included. + +#include "poisoned_hash_helper.hpp" + +template <class T, size_t = sizeof(T)> +constexpr bool is_complete_imp(int) { return true; } +template <class> constexpr bool is_complete_imp(long) { return false; } +template <class T> constexpr bool is_complete() { return is_complete_imp<T>(0); } + +template <class T> struct has_complete_hash { + enum { value = is_complete<std::hash<T> >() }; +}; + +int main() { + static_assert(LibraryHashTypes::assertTrait<has_complete_hash, false>(), ""); +} diff --git a/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp b/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp new file mode 100644 index 0000000000000..250d06d2b9029 --- /dev/null +++ b/test/support/test.workarounds/c1xx_broken_nullptr_conversion_operator.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// Verify TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR. + +#include <type_traits> + +#include "test_workarounds.h" + +struct ConvertsToNullptr { + using DestType = decltype(nullptr); + operator DestType() const { return nullptr; } +}; + +int main() { +#if defined(TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR) + static_assert(!std::is_convertible<ConvertsToNullptr, decltype(nullptr)>::value, ""); +#else + static_assert(std::is_convertible<ConvertsToNullptr, decltype(nullptr)>::value, ""); +#endif +} diff --git a/test/support/test_macros.h b/test/support/test_macros.h index 40d366ab19ddf..cee1419407b90 100644 --- a/test/support/test_macros.h +++ b/test/support/test_macros.h @@ -13,6 +13,11 @@ #include <ciso646> // Get STL specific macros like _LIBCPP_VERSION +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#endif + #define TEST_CONCAT1(X, Y) X##Y #define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y) @@ -47,6 +52,17 @@ #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0 #endif +#if defined(__clang__) +#define TEST_COMPILER_CLANG +# if defined(__apple_build_version__) +# define TEST_COMPILER_APPLE_CLANG +# endif +#elif defined(_MSC_VER) +# define TEST_COMPILER_C1XX +#elif defined(__GNUC__) +# define TEST_COMPILER_GCC +#endif + #if defined(__apple_build_version__) #define TEST_APPLE_CLANG_VER (__clang_major__ * 100) + __clang_minor__ #elif defined(__clang_major__) @@ -90,6 +106,7 @@ #define TEST_ALIGNAS(...) alignas(__VA_ARGS__) #define TEST_CONSTEXPR constexpr #define TEST_NOEXCEPT noexcept +#define TEST_NOEXCEPT_FALSE noexcept(false) #define TEST_NOEXCEPT_COND(...) noexcept(__VA_ARGS__) # if TEST_STD_VER >= 14 # define TEST_CONSTEXPR_CXX14 constexpr @@ -107,6 +124,7 @@ #define TEST_CONSTEXPR #define TEST_CONSTEXPR_CXX14 #define TEST_NOEXCEPT throw() +#define TEST_NOEXCEPT_FALSE #define TEST_NOEXCEPT_COND(...) #define TEST_THROW_SPEC(...) throw(__VA_ARGS__) #endif @@ -134,11 +152,16 @@ #define TEST_NORETURN [[noreturn]] #endif +#if TEST_STD_VER < 11 +#define ASSERT_NOEXCEPT(...) +#define ASSERT_NOT_NOEXCEPT(...) +#else #define ASSERT_NOEXCEPT(...) \ static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept") #define ASSERT_NOT_NOEXCEPT(...) \ static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept") +#endif /* Macros for testing libc++ specific behavior and extensions */ #if defined(_LIBCPP_VERSION) @@ -163,7 +186,7 @@ struct is_same<T, T> { enum {value = 1}; }; } // namespace test_macros_detail #define ASSERT_SAME_TYPE(...) \ - static_assert(test_macros_detail::is_same<__VA_ARGS__>::value, \ + static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \ "Types differ uexpectedly") #ifndef TEST_HAS_NO_EXCEPTIONS @@ -177,4 +200,22 @@ struct is_same<T, T> { enum {value = 1}; }; #endif #endif +#if defined(__GNUC__) || defined(__clang__) +template <class Tp> +inline void DoNotOptimize(Tp const& value) { + asm volatile("" : : "g"(value) : "memory"); +} +#else +#include <intrin.h> +template <class Tp> +inline void DoNotOptimize(Tp const& value) { + const volatile void* volatile = __builtin_addressof(value); + _ReadWriteBarrier(); +} +#endif + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + #endif // SUPPORT_TEST_MACROS_HPP diff --git a/test/support/test_memory_resource.hpp b/test/support/test_memory_resource.hpp index 49dc1739a9626..b3472c8b61055 100644 --- a/test/support/test_memory_resource.hpp +++ b/test/support/test_memory_resource.hpp @@ -25,7 +25,7 @@ // FIXME: This is a hack to allow uses_allocator_types.hpp to work with // erased_type. However we can't define that behavior directly in the header -// because it con't include <experimental/memory_resource> +// because it can't include <experimental/memory_resource> template <> struct TransformErasedTypeAlloc<std::experimental::erased_type> { using type = std::experimental::pmr::memory_resource*; diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/test/support/test_workarounds.h index 74d24fd488b65..affdd10259431 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp +++ b/test/support/test_workarounds.h @@ -1,3 +1,4 @@ +// -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure @@ -7,17 +8,13 @@ // //===----------------------------------------------------------------------===// -// <memory> +#ifndef SUPPORT_TEST_WORKAROUNDS_H +#define SUPPORT_TEST_WORKAROUNDS_H -// unique_ptr +#include "test_macros.h" -// Test unique_ptr default ctor +#if defined(TEST_COMPILER_C1XX) +# define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR +#endif -// default unique_ptr ctor should require non-pointer Deleter - -#include <memory> - -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p; -} +#endif // SUPPORT_TEST_WORKAROUNDS_H diff --git a/test/support/unique_ptr_test_helper.h b/test/support/unique_ptr_test_helper.h new file mode 100644 index 0000000000000..6fb9eaa24679d --- /dev/null +++ b/test/support/unique_ptr_test_helper.h @@ -0,0 +1,158 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_SUPPORT_UNIQUE_PTR_TEST_HELPER_H +#define TEST_SUPPORT_UNIQUE_PTR_TEST_HELPER_H + +#include <memory> +#include <type_traits> + +#include "test_macros.h" +#include "deleter_types.h" + +struct A { + static int count; + A() { ++count; } + A(const A&) { ++count; } + virtual ~A() { --count; } +}; + +int A::count = 0; + +struct B : public A { + static int count; + B() { ++count; } + B(const B&) { ++count; } + virtual ~B() { --count; } +}; + +int B::count = 0; + +template <class T> +typename std::enable_if<!std::is_array<T>::value, T*>::type +newValue(int num_elements) { + assert(num_elements == 1); + return new T; +} + +template <class T> +typename std::enable_if<std::is_array<T>::value, + typename std::remove_all_extents<T>::type*>::type +newValue(int num_elements) { + typedef typename std::remove_all_extents<T>::type VT; + assert(num_elements >= 1); + return new VT[num_elements]; +} + +struct IncompleteType; + +void checkNumIncompleteTypeAlive(int i); +int getNumIncompleteTypeAlive(); +IncompleteType* getNewIncomplete(); +IncompleteType* getNewIncompleteArray(int size); + +#if TEST_STD_VER >= 11 +template <class ThisT, class ...Args> +struct args_is_this_type : std::false_type {}; + +template <class ThisT, class A1> +struct args_is_this_type<ThisT, A1> : std::is_same<ThisT, typename std::decay<A1>::type> {}; +#endif + +template <class IncompleteT = IncompleteType, + class Del = std::default_delete<IncompleteT> > +struct StoresIncomplete { + static_assert((std::is_same<IncompleteT, IncompleteType>::value || + std::is_same<IncompleteT, IncompleteType[]>::value), ""); + + std::unique_ptr<IncompleteT, Del> m_ptr; + +#if TEST_STD_VER >= 11 + StoresIncomplete(StoresIncomplete const&) = delete; + StoresIncomplete(StoresIncomplete&&) = default; + + template <class ...Args> + StoresIncomplete(Args&&... args) : m_ptr(std::forward<Args>(args)...) { + static_assert(!args_is_this_type<StoresIncomplete, Args...>::value, ""); + } +#else +private: + StoresIncomplete(); + StoresIncomplete(StoresIncomplete const&); +public: +#endif + + ~StoresIncomplete(); + + IncompleteType* get() const { return m_ptr.get(); } + Del& get_deleter() { return m_ptr.get_deleter(); } +}; + +#if TEST_STD_VER >= 11 +template <class IncompleteT = IncompleteType, + class Del = std::default_delete<IncompleteT>, class... Args> +void doIncompleteTypeTest(int expect_alive, Args&&... ctor_args) { + using ValueT = typename std::remove_all_extents<IncompleteT>::type; + checkNumIncompleteTypeAlive(expect_alive); + { + StoresIncomplete<IncompleteT, Del> sptr(std::forward<Args>(ctor_args)...); + checkNumIncompleteTypeAlive(expect_alive); + if (expect_alive == 0) + assert(sptr.get() == nullptr); + else + assert(sptr.get() != nullptr); + } + checkNumIncompleteTypeAlive(0); +} +#endif + +#define INCOMPLETE_TEST_EPILOGUE() \ + int is_incomplete_test_anchor = is_incomplete_test(); \ + \ + struct IncompleteType { \ + static int count; \ + IncompleteType() { ++count; } \ + ~IncompleteType() { --count; } \ + }; \ + \ + int IncompleteType::count = 0; \ + \ + void checkNumIncompleteTypeAlive(int i) { \ + assert(IncompleteType::count == i); \ + } \ + int getNumIncompleteTypeAlive() { return IncompleteType::count; } \ + IncompleteType* getNewIncomplete() { return new IncompleteType; } \ + IncompleteType* getNewIncompleteArray(int size) { \ + return new IncompleteType[size]; \ + } \ + \ + template <class IncompleteT, class Del> \ + StoresIncomplete<IncompleteT, Del>::~StoresIncomplete() {} +# + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvariadic-macros" +#endif + +#if TEST_STD_VER >= 11 +#define DEFINE_AND_RUN_IS_INCOMPLETE_TEST(...) \ + static int is_incomplete_test() { __VA_ARGS__ return 0; } \ + INCOMPLETE_TEST_EPILOGUE() +#else +#define DEFINE_AND_RUN_IS_INCOMPLETE_TEST(...) \ + static int is_incomplete_test() { return 0; } \ + INCOMPLETE_TEST_EPILOGUE() +#endif + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +#endif // TEST_SUPPORT_UNIQUE_PTR_TEST_HELPER_H diff --git a/test/testit b/test/testit deleted file mode 100755 index cac668497fa56..0000000000000 --- a/test/testit +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/sh -# //===--------------------------- testit ---------------------------------===// -# // -# // The LLVM Compiler Infrastructure -# // -# // This file is distributed under the University of Illinois Open Source -# // License. See LICENSE.TXT for details. -# // -# //===--------------------------------------------------------------------===// - -currentpath=`pwd` -origpath=$currentpath -currentdir=`basename $currentpath` -while [ $currentdir != "test" ]; do - if [ $currentdir = "/" ] - then - echo "current directory must be in or under \"test\"." - exit 1 - fi - cd .. - currentpath=`pwd` - currentdir=`basename $currentpath` -done - -cd .. -LIBCXX_ROOT=`pwd` -cd $origpath - -if [ -z "$CC" ] -then - if which xcrun >/dev/null - then - CC="xcrun clang++" - else - CC=clang++ - fi -fi - -if [ -z "$CXX_LANG" ] -then - CXX_LANG=c++11 -fi -if [ -z "$OPTIONS" ] -then - OPTIONS="-std=${CXX_LANG} -stdlib=libc++ -nostdinc++" -fi -OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support" - -if [ -z "$HEADER_INCLUDE" ] -then - HEADER_INCLUDE="-I$LIBCXX_ROOT/include" -fi - -if [ -z "$SOURCE_LIB" ] -then - SOURCE_LIB="-L$LIBCXX_ROOT/lib" -fi - -case $TRIPLE in - *-*-mingw* | *-*-cygwin* | *-*-win*) - TEST_EXE=test.exe - ;; - *) - TEST_EXE=a.out - ;; -esac - -case $(uname -s) in - NetBSD) - THREAD_FLAGS=-lpthread - ;; -esac - -FAIL=0 -PASS=0 -UNIMPLEMENTED=0 -IMPLEMENTED_FAIL=0 -IMPLEMENTED_PASS=0 - -afunc() { - fail=0 - pass=0 - if (ls ${TEST_PREFIX}*fail.cpp > /dev/null 2>&1) - then - for FILE in $(ls ${TEST_PREFIX}*fail.cpp); do - if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1 - then - rm ./$TEST_EXE - echo "$FILE should not compile" - fail=$(($fail+1)) - else - pass=$(($pass+1)) - fi - done - fi - - if (ls ${TEST_PREFIX}*pass.cpp > /dev/null 2>&1) - then - for FILE in $(ls ${TEST_PREFIX}*pass.cpp); do - if [ "$VERBOSE" ] - then - echo "Running test: " $FILE - fi - if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE - then - if ./$TEST_EXE - then - rm ./$TEST_EXE - pass=$(($pass+1)) - else - echo "`pwd`/$FILE failed at run time" - echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) - fail=$(($fail+1)) - rm ./$TEST_EXE - fi - else - echo "`pwd`/$FILE failed to compile" - echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) - fail=$(($fail+1)) - fi - done - fi - - if [ $fail -gt 0 ] - then - echo "failed $fail tests in `pwd`" - IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1)) - fi - if [ $pass -gt 0 ] - then - echo "passed $pass tests in `pwd`" - if [ $fail -eq 0 ] - then - IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1)) - fi - fi - if [ $fail -eq 0 -a $pass -eq 0 ] - then - echo "not implemented: `pwd`" - UNIMPLEMENTED=$(($UNIMPLEMENTED+1)) - fi - - FAIL=$(($FAIL+$fail)) - PASS=$(($PASS+$pass)) - - for FILE in * - do - if [ -d "$FILE" ]; - then - cd $FILE - if [ $FILE = thread -o $1 = yes ]; then - afunc yes - else - afunc no - fi - cd .. - fi - done -} - -afunc no - -echo "****************************************************" -echo "Results for `pwd`:" -echo "using `$CC --version`" -echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB" -echo "----------------------------------------------------" -echo "sections without tests : $UNIMPLEMENTED" -echo "sections with failures : $IMPLEMENTED_FAIL" -echo "sections without failures: $IMPLEMENTED_PASS" -echo " + ----" -echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))" -echo "----------------------------------------------------" -echo "number of tests failed : $FAIL" -echo "number of tests passed : $PASS" -echo " + ----" -echo "total number of tests : $(($FAIL+$PASS))" -echo "****************************************************" - -exit $FAIL |