aboutsummaryrefslogtreecommitdiff
path: root/test/libcxx
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:54 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:54 +0000
commit4a2db4d30e1653093d4d8b06e8221e2f8b723507 (patch)
tree941a9d805eb2afbba58f445381819ba0e1dc355f /test/libcxx
parentcb08bb04c85c6dcd3d951725505317c31eeff323 (diff)
Vendor import of libc++ trunk r291274:vendor/libc++/libc++-trunk-r291274
Notes
Notes: svn path=/vendor/libc++/dist/; revision=311538 svn path=/vendor/libc++/libc++-trunk-r291274/; revision=311539; tag=vendor/libc++/libc++-trunk-r291274
Diffstat (limited to 'test/libcxx')
-rw-r--r--test/libcxx/test/config.py79
-rw-r--r--test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp46
-rw-r--r--test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp38
-rw-r--r--test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp31
-rw-r--r--test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp28
-rw-r--r--test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp36
-rw-r--r--test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp24
7 files changed, 210 insertions, 72 deletions
diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py
index dd90e7a37430..7043b8a01c4a 100644
--- a/test/libcxx/test/config.py
+++ b/test/libcxx/test/config.py
@@ -57,7 +57,9 @@ class Configuration(object):
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
@@ -95,6 +97,13 @@ class Configuration(object):
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()
@@ -171,20 +180,25 @@ class Configuration(object):
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:
+ 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)
+ 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
@@ -194,6 +208,25 @@ class Configuration(object):
self.config.available_features.add('%s-%s.%s' % (
cxx_type, maj_v, min_v))
+ def _configure_clang_cl(self, clang_path):
+ assert self.cxx_is_clang_cl
+ # FIXME: don't hardcode the target
+ flags = ['-fms-compatibility-version=19.00',
+ '--target=i686-unknown-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))
@@ -335,9 +368,13 @@ class Configuration(object):
if self.get_lit_bool('has_libatomic', False):
self.config.available_features.add('libatomic')
- if '__cpp_if_constexpr' not in self.cxx.dumpMacros():
+ 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:
@@ -349,6 +386,9 @@ class Configuration(object):
# Configure extra flags
compile_flags_str = self.get_lit_conf('compile_flags', '')
self.cxx.compile_flags += shlex.split(compile_flags_str)
+ # FIXME: Can we remove this?
+ if self.is_windows:
+ 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
@@ -396,7 +436,8 @@ class Configuration(object):
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++':
+ 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()
@@ -412,9 +453,11 @@ class Configuration(object):
self.lit_config.fatal("cxx_headers='%s' is not a directory."
% cxx_headers)
self.cxx.compile_flags += ['-I' + cxx_headers]
- 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]
+ 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
@@ -455,6 +498,8 @@ class Configuration(object):
# 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])
@@ -530,6 +575,9 @@ class Configuration(object):
# 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', '-lmsvcrtd']
self.configure_link_flags_cxx_library()
self.configure_link_flags_abi_library()
self.configure_extra_library_flags()
@@ -554,15 +602,16 @@ class Configuration(object):
if not self.use_system_cxx_lib:
if self.cxx_library_root:
self.cxx.link_flags += ['-L' + self.cxx_library_root]
- if self.cxx_runtime_root:
+ if self.cxx_runtime_root and not self.is_windows:
self.cxx.link_flags += ['-Wl,-rpath,' + 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,
- '-Wl,-rpath,' + 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]
def configure_link_flags_cxx_library(self):
libcxx_experimental = self.get_lit_bool('enable_experimental', default=False)
@@ -575,7 +624,10 @@ class Configuration(object):
else:
cxx_library_root = self.get_lit_conf('cxx_library_root')
if cxx_library_root:
- abs_path = os.path.join(cxx_library_root, 'libc++.a')
+ 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++']
@@ -594,7 +646,8 @@ class Configuration(object):
else:
cxxabi_library_root = self.get_lit_conf('abi_library_path')
if cxxabi_library_root:
- abs_path = os.path.join(cxxabi_library_root, 'libc++abi.a')
+ 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']
diff --git a/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp b/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp
new file mode 100644
index 000000000000..6d49cea8ba1f
--- /dev/null
+++ b/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.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>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+#include "test_macros.h"
+
+// libc++ doesn't offer std::pointer_safety in C++03 under the new ABI
+#if TEST_STD_VER < 11 && defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE)
+#define TEST_IS_UNSUPPORTED
+#endif
+
+#ifndef TEST_IS_UNSUPPORTED
+void test_pr26961() {
+ std::pointer_safety d;
+ d = std::get_pointer_safety();
+ assert(d == std::get_pointer_safety());
+}
+#endif
+
+int main()
+{
+#ifndef TEST_IS_UNSUPPORTED
+ {
+ // Test that std::pointer_safety is still offered in C++03 under the old ABI.
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+ }
+ {
+ test_pr26961();
+ }
+#endif
+}
diff --git a/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp b/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp
new file mode 100644
index 000000000000..752edb6dadd9
--- /dev/null
+++ b/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+// The pointer_safety interface is no longer provided in C++03 in the new ABI.
+// XFAIL: c++98, c++03
+
+// MODULES_DEFINES: _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ static_assert(std::is_enum<std::pointer_safety>::value, "");
+ static_assert(!std::is_convertible<std::pointer_safety, int>::value, "");
+ static_assert(std::is_same<
+ std::underlying_type<std::pointer_safety>::type,
+ unsigned char
+ >::value, "");
+ }
+ {
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+ }
+}
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 a94aa2f78299..cb17dfeb071a 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
@@ -10,8 +10,9 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// Clang 3.8 doesn't generate constexpr special members correctly.
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
+// 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
// <variant>
@@ -63,7 +64,7 @@ struct TCopyAssignNTMoveAssign {
int value;
};
-static_assert(std::is_trivially_copy_assignable_v<TCopyAssignNTMoveAssign>);
+static_assert(std::is_trivially_copy_assignable_v<TCopyAssignNTMoveAssign>, "");
void test_copy_assignment_sfinae() {
{
@@ -99,8 +100,8 @@ void test_copy_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 0);
- static_assert(result.value == 42);
+ static_assert(result.index == 0, "");
+ static_assert(result.value == 42, "");
}
{
struct {
@@ -113,8 +114,8 @@ void test_copy_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42l);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42l, "");
}
{
struct {
@@ -127,8 +128,8 @@ void test_copy_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
{
struct {
@@ -141,8 +142,8 @@ void test_copy_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
}
@@ -158,8 +159,8 @@ void test_copy_assignment_different_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42l);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42l, "");
}
{
struct {
@@ -172,8 +173,8 @@ void test_copy_assignment_different_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
}
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 a3d92472dd5e..286a623882fe 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
@@ -10,9 +10,9 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// Clang 3.8 doesn't generate constexpr special members correctly.
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
-
+// 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
// <variant>
@@ -64,7 +64,7 @@ struct TMoveAssignNTCopyAssign {
int value;
};
-static_assert(std::is_trivially_move_assignable_v<TMoveAssignNTCopyAssign>);
+static_assert(std::is_trivially_move_assignable_v<TMoveAssignNTCopyAssign>, "");
void test_move_assignment_sfinae() {
{
@@ -100,8 +100,8 @@ void test_move_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 0);
- static_assert(result.value == 42);
+ static_assert(result.index == 0, "");
+ static_assert(result.value == 42, "");
}
{
struct {
@@ -114,8 +114,8 @@ void test_move_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42l);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42l, "");
}
{
struct {
@@ -128,8 +128,8 @@ void test_move_assignment_same_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
}
@@ -145,8 +145,8 @@ void test_move_assignment_different_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42l);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42l, "");
}
{
struct {
@@ -159,8 +159,8 @@ void test_move_assignment_different_index() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
}
diff --git a/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
index 59c433050590..0d30a78a48ac 100644
--- a/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
+++ b/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
@@ -72,45 +72,45 @@ void test_copy_ctor_sfinae() {
void test_copy_ctor_basic() {
{
constexpr std::variant<int> v(std::in_place_index<0>, 42);
- static_assert(v.index() == 0);
+ static_assert(v.index() == 0, "");
constexpr std::variant<int> v2 = v;
- static_assert(v2.index() == 0);
- static_assert(std::get<0>(v2) == 42);
+ static_assert(v2.index() == 0, "");
+ static_assert(std::get<0>(v2) == 42, "");
}
{
constexpr std::variant<int, long> v(std::in_place_index<1>, 42);
- static_assert(v.index() == 1);
+ static_assert(v.index() == 1, "");
constexpr std::variant<int, long> v2 = v;
- static_assert(v2.index() == 1);
- static_assert(std::get<1>(v2) == 42);
+ static_assert(v2.index() == 1, "");
+ static_assert(std::get<1>(v2) == 42, "");
}
{
constexpr std::variant<TCopy> v(std::in_place_index<0>, 42);
- static_assert(v.index() == 0);
+ static_assert(v.index() == 0, "");
constexpr std::variant<TCopy> v2(v);
- static_assert(v2.index() == 0);
- static_assert(std::get<0>(v2).value == 42);
+ static_assert(v2.index() == 0, "");
+ static_assert(std::get<0>(v2).value == 42, "");
}
{
constexpr std::variant<int, TCopy> v(std::in_place_index<1>, 42);
- static_assert(v.index() == 1);
+ static_assert(v.index() == 1, "");
constexpr std::variant<int, TCopy> v2(v);
- static_assert(v2.index() == 1);
- static_assert(std::get<1>(v2).value == 42);
+ static_assert(v2.index() == 1, "");
+ static_assert(std::get<1>(v2).value == 42, "");
}
{
constexpr std::variant<TCopyNTMove> v(std::in_place_index<0>, 42);
- static_assert(v.index() == 0);
+ static_assert(v.index() == 0, "");
constexpr std::variant<TCopyNTMove> v2(v);
- static_assert(v2.index() == 0);
- static_assert(std::get<0>(v2).value == 42);
+ static_assert(v2.index() == 0, "");
+ static_assert(std::get<0>(v2).value == 42, "");
}
{
constexpr std::variant<int, TCopyNTMove> v(std::in_place_index<1>, 42);
- static_assert(v.index() == 1);
+ static_assert(v.index() == 1, "");
constexpr std::variant<int, TCopyNTMove> v2(v);
- static_assert(v2.index() == 1);
- static_assert(std::get<1>(v2).value == 42);
+ static_assert(v2.index() == 1, "");
+ static_assert(std::get<1>(v2).value == 42, "");
}
}
diff --git a/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
index e67a495d9799..91e8c194d144 100644
--- a/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ b/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -82,8 +82,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 0);
- static_assert(result.value == 42);
+ static_assert(result.index == 0, "");
+ static_assert(result.value == 42, "");
}
{
struct {
@@ -94,8 +94,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value == 42, "");
}
{
struct {
@@ -106,8 +106,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 0);
- static_assert(result.value.value == 42);
+ static_assert(result.index == 0, "");
+ static_assert(result.value.value == 42, "");
}
{
struct {
@@ -118,8 +118,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value.value == 42, "");
}
{
struct {
@@ -130,8 +130,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 0);
- static_assert(result.value.value == 42);
+ static_assert(result.index == 0, "");
+ static_assert(result.value.value == 42, "");
}
{
struct {
@@ -142,8 +142,8 @@ void test_move_ctor_basic() {
}
} test;
constexpr auto result = test();
- static_assert(result.index == 1);
- static_assert(result.value.value == 42);
+ static_assert(result.index == 1, "");
+ static_assert(result.value.value == 42, "");
}
}