aboutsummaryrefslogtreecommitdiff
path: root/test/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/libcxx')
-rw-r--r--test/libcxx/algorithms/debug_less.pass.cpp2
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp2
-rw-r--r--test/libcxx/containers/unord/next_pow2.pass.cpp12
-rw-r--r--test/libcxx/depr/depr.c.headers/complex.h.pass.cpp1
-rw-r--r--test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp1
-rw-r--r--test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp24
-rw-r--r--test/libcxx/diagnostics/nodiscard.fail.cpp24
-rw-r--r--test/libcxx/diagnostics/nodiscard.pass.cpp25
-rw-r--r--test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp2
-rw-r--r--test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp2
-rw-r--r--test/libcxx/fuzzing/nth_element.cpp38
-rw-r--r--test/libcxx/fuzzing/partial_sort.cpp38
-rw-r--r--test/libcxx/fuzzing/partial_sort_copy.cpp38
-rw-r--r--test/libcxx/fuzzing/partition.cpp38
-rw-r--r--test/libcxx/fuzzing/partition_copy.cpp38
-rw-r--r--test/libcxx/fuzzing/regex_ECMAScript.cpp37
-rw-r--r--test/libcxx/fuzzing/regex_POSIX.cpp37
-rw-r--r--test/libcxx/fuzzing/regex_awk.cpp37
-rw-r--r--test/libcxx/fuzzing/regex_egrep.cpp37
-rw-r--r--test/libcxx/fuzzing/regex_extended.cpp37
-rw-r--r--test/libcxx/fuzzing/regex_grep.cpp37
-rw-r--r--test/libcxx/fuzzing/sort.cpp38
-rw-r--r--test/libcxx/fuzzing/stable_partition.cpp38
-rw-r--r--test/libcxx/fuzzing/stable_sort.cpp38
-rw-r--r--test/libcxx/fuzzing/unique.cpp38
-rw-r--r--test/libcxx/fuzzing/unique_copy.cpp38
-rw-r--r--test/libcxx/iterators/trivial_iterators.pass.cpp72
-rw-r--r--test/libcxx/language.support/cxa_deleted_virtual.pass.cpp27
-rw-r--r--test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp1
-rw-r--r--test/libcxx/selftest/test_macros.pass.cpp2
-rw-r--r--test/libcxx/strings/iterators.noexcept.pass.cpp2
-rw-r--r--test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp2
-rw-r--r--test/libcxx/type_traits/lazy_metafunctions.pass.cpp2
-rw-r--r--test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp2
-rw-r--r--test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp2
-rw-r--r--test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.fail.cpp2
-rw-r--r--test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.pass.cpp2
-rw-r--r--test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp68
38 files changed, 815 insertions, 66 deletions
diff --git a/test/libcxx/algorithms/debug_less.pass.cpp b/test/libcxx/algorithms/debug_less.pass.cpp
index 2e875ff277c4..e030f64e5dd9 100644
--- a/test/libcxx/algorithms/debug_less.pass.cpp
+++ b/test/libcxx/algorithms/debug_less.pass.cpp
@@ -164,4 +164,4 @@ void test_failing() {
int main() {
test_passing();
test_failing();
-} \ No newline at end of file
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp
index 589af7cc453b..6e25b0c3cbcf 100644
--- a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp
+++ b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp
@@ -27,4 +27,4 @@ int main()
std::list<int> v2(3);
v1.insert(v2.begin(), 4);
assert(false);
-} \ No newline at end of file
+}
diff --git a/test/libcxx/containers/unord/next_pow2.pass.cpp b/test/libcxx/containers/unord/next_pow2.pass.cpp
index 3784eb87cebb..a878da4f5aa6 100644
--- a/test/libcxx/containers/unord/next_pow2.pass.cpp
+++ b/test/libcxx/containers/unord/next_pow2.pass.cpp
@@ -54,12 +54,12 @@ test_next_pow2()
assert(std::__next_hash_pow2(pow2) == pow2);
}
- test_next_pow2_val(3);
- test_next_pow2_val(7);
- test_next_pow2_val(9);
- test_next_pow2_val(15);
- test_next_pow2_val(127);
- test_next_pow2_val(129);
+ test_next_pow2_val(3);
+ test_next_pow2_val(7);
+ test_next_pow2_val(9);
+ test_next_pow2_val(15);
+ test_next_pow2_val(127);
+ test_next_pow2_val(129);
}
// Note: this is only really useful when run with -fsanitize=undefined.
diff --git a/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp b/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
index da0707990d80..7abe8e0a064d 100644
--- a/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
+++ b/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
@@ -18,4 +18,5 @@
int main()
{
std::complex<double> d;
+ (void)d;
}
diff --git a/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp b/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
index a2ef814dcae1..931e3a32f9ce 100644
--- a/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
+++ b/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
@@ -18,6 +18,7 @@
int main()
{
std::complex<double> cd;
+ (void)cd;
double x = sin(1.0);
(void)x; // to placate scan-build
}
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
index f06dbb927acb..1847dac2ed00 100644
--- a/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
+++ b/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
@@ -24,25 +24,25 @@ 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 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));
+ 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));
+ 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));
+ assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
+ assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
}
diff --git a/test/libcxx/diagnostics/nodiscard.fail.cpp b/test/libcxx/diagnostics/nodiscard.fail.cpp
new file mode 100644
index 000000000000..903a24a72805
--- /dev/null
+++ b/test/libcxx/diagnostics/nodiscard.fail.cpp
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
+// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <__config>
+
+_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
+
+int main ()
+{
+ foo(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
diff --git a/test/libcxx/diagnostics/nodiscard.pass.cpp b/test/libcxx/diagnostics/nodiscard.pass.cpp
new file mode 100644
index 000000000000..d308248cff22
--- /dev/null
+++ b/test/libcxx/diagnostics/nodiscard.pass.cpp
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
+// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
+#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
+#include <__config>
+
+_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
+
+int main ()
+{
+ foo(); // no error here!
+}
diff --git a/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp
index a98a9ccd2a80..aea46f10c9bc 100644
--- a/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp
+++ b/test/libcxx/experimental/filesystem/class.path/path.itr/iterator_db.pass.cpp
@@ -71,4 +71,4 @@ int main() {
assert(false);
} catch (int) {}
}
-} \ No newline at end of file
+}
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
index 6f839befb5cf..5a6f5304a061 100644
--- 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
@@ -23,7 +23,7 @@ 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"}}
+ // expected-error-re@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/fuzzing/nth_element.cpp b/test/libcxx/fuzzing/nth_element.cpp
new file mode 100644
index 000000000000..ee7f0d824c94
--- /dev/null
+++ b/test/libcxx/fuzzing/nth_element.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===----------------------- nth_element.cpp ------------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::nth_element(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/partial_sort.cpp b/test/libcxx/fuzzing/partial_sort.cpp
new file mode 100644
index 000000000000..0c5889dbde8e
--- /dev/null
+++ b/test/libcxx/fuzzing/partial_sort.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===-------------------------- partial_sort.cpp --------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::partial_sort(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/partial_sort_copy.cpp b/test/libcxx/fuzzing/partial_sort_copy.cpp
new file mode 100644
index 000000000000..368eed11bf7e
--- /dev/null
+++ b/test/libcxx/fuzzing/partial_sort_copy.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===----------------------- partial_sort_copy.cpp ------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::partial_sort_copy(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/partition.cpp b/test/libcxx/fuzzing/partition.cpp
new file mode 100644
index 000000000000..03eed8c925ac
--- /dev/null
+++ b/test/libcxx/fuzzing/partition.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===--------------------------- partition.cpp ----------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::partition(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/partition_copy.cpp b/test/libcxx/fuzzing/partition_copy.cpp
new file mode 100644
index 000000000000..68d821f632a6
--- /dev/null
+++ b/test/libcxx/fuzzing/partition_copy.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===------------------------ partition_copy.cpp --------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::partition_copy(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_ECMAScript.cpp b/test/libcxx/fuzzing/regex_ECMAScript.cpp
new file mode 100644
index 000000000000..2e57126022f3
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_ECMAScript.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===--------------------- regex_ECMAScript.cpp ---------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_ECMAScript(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_POSIX.cpp b/test/libcxx/fuzzing/regex_POSIX.cpp
new file mode 100644
index 000000000000..f0bd28919fe5
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_POSIX.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------- regex_POSIX.cpp ------------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_POSIX(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_awk.cpp b/test/libcxx/fuzzing/regex_awk.cpp
new file mode 100644
index 000000000000..2e57126022f3
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_awk.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===--------------------- regex_ECMAScript.cpp ---------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_ECMAScript(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_egrep.cpp b/test/libcxx/fuzzing/regex_egrep.cpp
new file mode 100644
index 000000000000..056869f5222c
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_egrep.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===------------------------ regex_egrep.cpp -----------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_egrep(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_extended.cpp b/test/libcxx/fuzzing/regex_extended.cpp
new file mode 100644
index 000000000000..ac850eb5cbb4
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_extended.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===---------------------- regex_extended.cpp ----------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_extended(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/regex_grep.cpp b/test/libcxx/fuzzing/regex_grep.cpp
new file mode 100644
index 000000000000..5b1dda293dfa
--- /dev/null
+++ b/test/libcxx/fuzzing/regex_grep.cpp
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===------------------------ regex_grep.cpp ------------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "b*c",
+ "ba?sf"
+ "lka*ea",
+ "adsf*kas;lnc441[0-9]1r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::regex_grep(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/sort.cpp b/test/libcxx/fuzzing/sort.cpp
new file mode 100644
index 000000000000..4c468948deb6
--- /dev/null
+++ b/test/libcxx/fuzzing/sort.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===--------------------------- sort.cpp ---------------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::sort(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/stable_partition.cpp b/test/libcxx/fuzzing/stable_partition.cpp
new file mode 100644
index 000000000000..c21e6489049c
--- /dev/null
+++ b/test/libcxx/fuzzing/stable_partition.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===--------------------- stable_partition.cpp ---------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::stable_partition(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/stable_sort.cpp b/test/libcxx/fuzzing/stable_sort.cpp
new file mode 100644
index 000000000000..1a7bbb9528e2
--- /dev/null
+++ b/test/libcxx/fuzzing/stable_sort.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===------------------------ stable_sort.cpp ----------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::stable_sort(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/unique.cpp b/test/libcxx/fuzzing/unique.cpp
new file mode 100644
index 000000000000..4bfa25a2b5c1
--- /dev/null
+++ b/test/libcxx/fuzzing/unique.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===--------------------------- unique.cpp -------------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::unique(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/fuzzing/unique_copy.cpp b/test/libcxx/fuzzing/unique_copy.cpp
new file mode 100644
index 000000000000..ed6fc7ea5513
--- /dev/null
+++ b/test/libcxx/fuzzing/unique_copy.cpp
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===------------------------ unique_copy.cpp -----------------------------===//
+//
+// The 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
+
+#include "fuzzing.h"
+#include <cassert>
+#include <cstring> // for strlen
+
+const char * test_cases[] = {
+ "",
+ "s",
+ "bac",
+ "bacasf"
+ "lkajseravea",
+ "adsfkajdsfjkas;lnc441324513,34535r34525234"
+ };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+
+int main ()
+{
+ for (size_t i = 0; i < k_num_tests; ++i)
+ {
+ const size_t size = std::strlen(test_cases[i]);
+ const uint8_t *data = (const uint8_t *) test_cases[i];
+ assert(0 == fuzzing::unique_copy(data, size));
+ }
+ return 0;
+}
diff --git a/test/libcxx/iterators/trivial_iterators.pass.cpp b/test/libcxx/iterators/trivial_iterators.pass.cpp
index fa3ebf260486..f30c13163ccc 100644
--- a/test/libcxx/iterators/trivial_iterators.pass.cpp
+++ b/test/libcxx/iterators/trivial_iterators.pass.cpp
@@ -126,42 +126,42 @@ int main()
static_assert((!std::__libcpp_is_trivial_iterator<NonThrowingIterator <char *> >::value), "");
-// Iterator classification
- static_assert(( std::__is_input_iterator <char *>::value), "" );
- static_assert(( std::__is_forward_iterator <char *>::value), "" );
- static_assert(( std::__is_bidirectional_iterator<char *>::value), "" );
- static_assert(( std::__is_random_access_iterator<char *>::value), "" );
- static_assert((!std::__is_exactly_input_iterator<char *>::value), "" );
-
- static_assert(( std::__is_input_iterator <input_iterator<char *> >::value), "" );
- static_assert((!std::__is_forward_iterator <input_iterator<char *> >::value), "" );
- static_assert((!std::__is_bidirectional_iterator<input_iterator<char *> >::value), "" );
- static_assert((!std::__is_random_access_iterator<input_iterator<char *> >::value), "" );
- static_assert(( std::__is_exactly_input_iterator<input_iterator<char *> >::value), "" );
-
- static_assert(( std::__is_input_iterator <forward_iterator<char *> >::value), "" );
- static_assert(( std::__is_forward_iterator <forward_iterator<char *> >::value), "" );
- static_assert((!std::__is_bidirectional_iterator<forward_iterator<char *> >::value), "" );
- static_assert((!std::__is_random_access_iterator<forward_iterator<char *> >::value), "" );
- static_assert((!std::__is_exactly_input_iterator<forward_iterator<char *> >::value), "" );
-
- static_assert(( std::__is_input_iterator <bidirectional_iterator<char *> >::value), "" );
- static_assert(( std::__is_forward_iterator <bidirectional_iterator<char *> >::value), "" );
- static_assert(( std::__is_bidirectional_iterator<bidirectional_iterator<char *> >::value), "" );
- static_assert((!std::__is_random_access_iterator<bidirectional_iterator<char *> >::value), "" );
- static_assert((!std::__is_exactly_input_iterator<bidirectional_iterator<char *> >::value), "" );
-
- static_assert(( std::__is_input_iterator <random_access_iterator<char *> >::value), "" );
- static_assert(( std::__is_forward_iterator <random_access_iterator<char *> >::value), "" );
- static_assert(( std::__is_bidirectional_iterator<random_access_iterator<char *> >::value), "" );
- static_assert(( std::__is_random_access_iterator<random_access_iterator<char *> >::value), "" );
- static_assert((!std::__is_exactly_input_iterator<random_access_iterator<char *> >::value), "" );
-
- static_assert(( std::__is_input_iterator <my_input_iterator<char *> >::value), "" );
- static_assert((!std::__is_forward_iterator <my_input_iterator<char *> >::value), "" );
- static_assert((!std::__is_bidirectional_iterator<my_input_iterator<char *> >::value), "" );
- static_assert((!std::__is_random_access_iterator<my_input_iterator<char *> >::value), "" );
- static_assert(( std::__is_exactly_input_iterator<my_input_iterator<char *> >::value), "" );
+// Iterator classification
+ static_assert(( std::__is_input_iterator <char *>::value), "" );
+ static_assert(( std::__is_forward_iterator <char *>::value), "" );
+ static_assert(( std::__is_bidirectional_iterator<char *>::value), "" );
+ static_assert(( std::__is_random_access_iterator<char *>::value), "" );
+ static_assert((!std::__is_exactly_input_iterator<char *>::value), "" );
+
+ static_assert(( std::__is_input_iterator <input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_forward_iterator <input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_bidirectional_iterator<input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_random_access_iterator<input_iterator<char *> >::value), "" );
+ static_assert(( std::__is_exactly_input_iterator<input_iterator<char *> >::value), "" );
+
+ static_assert(( std::__is_input_iterator <forward_iterator<char *> >::value), "" );
+ static_assert(( std::__is_forward_iterator <forward_iterator<char *> >::value), "" );
+ static_assert((!std::__is_bidirectional_iterator<forward_iterator<char *> >::value), "" );
+ static_assert((!std::__is_random_access_iterator<forward_iterator<char *> >::value), "" );
+ static_assert((!std::__is_exactly_input_iterator<forward_iterator<char *> >::value), "" );
+
+ static_assert(( std::__is_input_iterator <bidirectional_iterator<char *> >::value), "" );
+ static_assert(( std::__is_forward_iterator <bidirectional_iterator<char *> >::value), "" );
+ static_assert(( std::__is_bidirectional_iterator<bidirectional_iterator<char *> >::value), "" );
+ static_assert((!std::__is_random_access_iterator<bidirectional_iterator<char *> >::value), "" );
+ static_assert((!std::__is_exactly_input_iterator<bidirectional_iterator<char *> >::value), "" );
+
+ static_assert(( std::__is_input_iterator <random_access_iterator<char *> >::value), "" );
+ static_assert(( std::__is_forward_iterator <random_access_iterator<char *> >::value), "" );
+ static_assert(( std::__is_bidirectional_iterator<random_access_iterator<char *> >::value), "" );
+ static_assert(( std::__is_random_access_iterator<random_access_iterator<char *> >::value), "" );
+ static_assert((!std::__is_exactly_input_iterator<random_access_iterator<char *> >::value), "" );
+
+ static_assert(( std::__is_input_iterator <my_input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_forward_iterator <my_input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_bidirectional_iterator<my_input_iterator<char *> >::value), "" );
+ static_assert((!std::__is_random_access_iterator<my_input_iterator<char *> >::value), "" );
+ static_assert(( std::__is_exactly_input_iterator<my_input_iterator<char *> >::value), "" );
//
// iterators from libc++'s containers
diff --git a/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp b/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp
new file mode 100644
index 000000000000..ddef5d00e5da
--- /dev/null
+++ b/test/libcxx/language.support/cxa_deleted_virtual.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
+
+// Test exporting the symbol: "__cxa_deleted_virtual" in macosx
+// But don't expect the symbol to be exported in previous versions.
+//
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+struct S { virtual void f() = delete; virtual ~S() {} };
+int main() {
+ S *s = new S;
+ delete s;
+}
diff --git a/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
index 21aaa669fd43..cc98517b9f51 100644
--- a/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
+++ b/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -18,4 +18,5 @@
int main()
{
std::complex<double> d;
+ (void)d;
}
diff --git a/test/libcxx/selftest/test_macros.pass.cpp b/test/libcxx/selftest/test_macros.pass.cpp
index 69e75b788711..8d68c2184d65 100644
--- a/test/libcxx/selftest/test_macros.pass.cpp
+++ b/test/libcxx/selftest/test_macros.pass.cpp
@@ -56,7 +56,7 @@ void test_libcxx_macros()
# endif
#endif
-// ===== C++1z features =====
+// ===== C++17 features =====
}
int main()
diff --git a/test/libcxx/strings/iterators.noexcept.pass.cpp b/test/libcxx/strings/iterators.noexcept.pass.cpp
index 20b4e3d769e5..c9d2bf5c21d9 100644
--- a/test/libcxx/strings/iterators.noexcept.pass.cpp
+++ b/test/libcxx/strings/iterators.noexcept.pass.cpp
@@ -20,7 +20,7 @@
//
// MODULES_DEFINES: _LIBCPP_NO_EXCEPTIONS
-#define _LIBCPP_NO_EXCEPTIONS
+#define _LIBCPP_NO_EXCEPTIONS
#include <iterator>
#include <cassert>
diff --git a/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
index de225fe78384..7463b78af326 100644
--- a/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
+++ b/test/libcxx/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp
@@ -20,7 +20,7 @@
// notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
// Test that this function works with threads that were not created by
-// std::thread. See http://llvm.org/PR30202.
+// std::thread. See: https://bugs.llvm.org/show_bug.cgi?id=30202
#include <condition_variable>
diff --git a/test/libcxx/type_traits/lazy_metafunctions.pass.cpp b/test/libcxx/type_traits/lazy_metafunctions.pass.cpp
index 8f75080ab956..8cf47a039594 100644
--- a/test/libcxx/type_traits/lazy_metafunctions.pass.cpp
+++ b/test/libcxx/type_traits/lazy_metafunctions.pass.cpp
@@ -134,4 +134,4 @@ int main() {
LazyNotTest();
LazyAndTest();
LazyOrTest();
-} \ No newline at end of file
+}
diff --git a/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp b/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
index 803c501f8c9e..58bb5fd10848 100644
--- a/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
+++ b/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
@@ -213,4 +213,4 @@ int main() {
TestCase<ArgType volatile>::run();
TestCase<ArgType const volatile>::run();
TestCase<ArgType*>::run();
-} \ No newline at end of file
+}
diff --git a/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp b/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
index 87cd29264b4e..c94ce75fe685 100644
--- a/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
+++ b/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
@@ -36,7 +36,7 @@ int main() {
SPtr<2> s2(getFn<2>(), Deleter{}); // OK
SPtr<3> s3(nullptr, Deleter{}); // OK
}
- // expected-error@memory:* 2 {{static_assert failed "default_delete cannot be instantiated for function types"}}
+ // expected-error-re@memory:* 2 {{static_assert failed{{.*}} "default_delete cannot be instantiated for function types"}}
{
SPtr<4> s4(getFn<4>()); // expected-note {{requested here}}
SPtr<5> s5(getFn<5>(), std::default_delete<FnType<5>>{}); // expected-note {{requested here}}
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 76d5f0d679f6..1cc3c73d10fe 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
@@ -22,7 +22,7 @@
int main() {
std::allocator<void> alloc;
- // expected-error@tuple:* 4 {{static_assert failed "Attempted to construct a reference element in a tuple with an rvalue"}}
+ // expected-error-re@tuple:* 4 {{static_assert failed{{.*}} "Attempted to construct a reference element in a tuple with an rvalue"}}
// bind lvalue to rvalue
std::tuple<int const&> t(42); // expected-note {{requested here}}
diff --git a/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.pass.cpp b/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.pass.cpp
index a90a2912d3a8..78446976431e 100644
--- a/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.pass.cpp
+++ b/test/libcxx/utilities/tuple/tuple.tuple/diagnose_reference_binding.pass.cpp
@@ -68,4 +68,4 @@ int main() {
std::tuple<int const&> t4(std::allocator_arg, alloc, cr);
assert(&std::get<0>(t4) == &x);
}
-} \ No newline at end of file
+}
diff --git a/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
new file mode 100644
index 000000000000..a836ef5169ef
--- /dev/null
+++ b/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <variant>
+
+// template <class ...Types> class variant;
+
+#include <limits>
+#include <type_traits>
+#include <utility>
+#include <variant>
+
+template <class Sequence>
+struct make_variant_imp;
+
+template <size_t ...Indices>
+struct make_variant_imp<std::integer_sequence<size_t, Indices...>> {
+ using type = std::variant<decltype((Indices, char(0)))...>;
+};
+
+template <size_t N>
+using make_variant_t = typename make_variant_imp<std::make_index_sequence<N>>::type;
+
+constexpr bool ExpectEqual =
+#ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
+ false;
+#else
+ true;
+#endif
+
+template <class IndexType>
+void test_index_type() {
+ using Lim = std::numeric_limits<IndexType>;
+ using T1 = make_variant_t<Lim::max() - 1>;
+ using T2 = make_variant_t<Lim::max()>;
+ static_assert((sizeof(T1) == sizeof(T2)) == ExpectEqual, "");
+}
+
+template <class IndexType>
+void test_index_internals() {
+ using Lim = std::numeric_limits<IndexType>;
+ static_assert(std::__choose_index_type(Lim::max() -1) !=
+ std::__choose_index_type(Lim::max()), "");
+ static_assert(std::is_same_v<
+ std::__variant_index_t<Lim::max()-1>,
+ std::__variant_index_t<Lim::max()>
+ > == ExpectEqual, "");
+ using IndexT = std::__variant_index_t<Lim::max()-1>;
+ using IndexLim = std::numeric_limits<IndexT>;
+ static_assert(std::__variant_npos<IndexT> == IndexLim::max(), "");
+}
+
+int main() {
+ test_index_type<unsigned char>();
+ // This won't compile due to template depth issues.
+ //test_index_type<unsigned short>();
+ test_index_internals<unsigned char>();
+ test_index_internals<unsigned short>();
+}