summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorZoe Carver <z.zoelec2@gmail.com>2019-09-24 20:55:54 +0000
committerZoe Carver <z.zoelec2@gmail.com>2019-09-24 20:55:54 +0000
commit4278a9e6b5025d9480532c687ab57e3a50c21fae (patch)
tree5d26a75db6bd959a234bc1e23c664d2bbf6a8bec /libcxx/test
parent937b95583787086df2e9030d670ae4759b46c566 (diff)
downloadbcm5719-llvm-4278a9e6b5025d9480532c687ab57e3a50c21fae.tar.gz
bcm5719-llvm-4278a9e6b5025d9480532c687ab57e3a50c21fae.zip
[libc++] Remove C++03 variadics in shared_ptr
Summary: As suggested by @ldionne in D66178, this patch removes C++03 variadics //only//. Following patches will apply more updates. Reviewers: ldionne, EricWF, mclow.lists Subscribers: christof, dexonsmith, libcxx-commits, ldionne Tags: #libc Differential Revision: https://reviews.llvm.org/D67675 llvm-svn: 372780
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp81
-rw-r--r--libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp120
-rw-r--r--libcxx/test/support/min_allocator.h8
3 files changed, 80 insertions, 129 deletions
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
index 40d4639d881..72069456fa7 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++98, c++03
-
// <memory>
// shared_ptr
@@ -52,8 +50,87 @@ private:
int A::count = 0;
+struct Zero
+{
+ static int count;
+ Zero() {++count;}
+ Zero(Zero const &) {++count;}
+ ~Zero() {--count;}
+};
+
+int Zero::count = 0;
+
+struct One
+{
+ static int count;
+ int value;
+ explicit One(int v) : value(v) {++count;}
+ One(One const & o) : value(o.value) {++count;}
+ ~One() {--count;}
+};
+
+int One::count = 0;
+
+
+struct Two
+{
+ static int count;
+ int value;
+ Two(int v, int) : value(v) {++count;}
+ Two(Two const & o) : value(o.value) {++count;}
+ ~Two() {--count;}
+};
+
+int Two::count = 0;
+
+struct Three
+{
+ static int count;
+ int value;
+ Three(int v, int, int) : value(v) {++count;}
+ Three(Three const & o) : value(o.value) {++count;}
+ ~Three() {--count;}
+};
+
+int Three::count = 0;
+
+template <class Alloc>
+void test()
+{
+ int const bad = -1;
+ {
+ std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc());
+ assert(Zero::count == 1);
+ }
+ assert(Zero::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i);
+ assert(One::count == 1);
+ assert(p->value == i);
+ }
+ assert(One::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad);
+ assert(Two::count == 1);
+ assert(p->value == i);
+ }
+ assert(Two::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad);
+ assert(Three::count == 1);
+ assert(p->value == i);
+ }
+ assert(Three::count == 0);
+}
+
int main(int, char**)
{
+ test<bare_allocator<void> >();
+ test<test_allocator<void> >();
+
{
int i = 67;
char c = 'e';
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp
deleted file mode 100644
index 13c929dd4f7..00000000000
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// <memory>
-
-// shared_ptr
-
-// template<class T, class A, class... Args>
-// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
-
-
-#include <memory>
-#include <new>
-#include <cstdlib>
-#include <cassert>
-#include "test_macros.h"
-#include "test_allocator.h"
-#include "min_allocator.h"
-
-struct Zero
-{
- static int count;
- Zero() {++count;}
- Zero(Zero const &) {++count;}
- ~Zero() {--count;}
-};
-
-int Zero::count = 0;
-
-struct One
-{
- static int count;
- int value;
- explicit One(int v) : value(v) {++count;}
- One(One const & o) : value(o.value) {++count;}
- ~One() {--count;}
-};
-
-int One::count = 0;
-
-
-struct Two
-{
- static int count;
- int value;
- Two(int v, int) : value(v) {++count;}
- Two(Two const & o) : value(o.value) {++count;}
- ~Two() {--count;}
-};
-
-int Two::count = 0;
-
-struct Three
-{
- static int count;
- int value;
- Three(int v, int, int) : value(v) {++count;}
- Three(Three const & o) : value(o.value) {++count;}
- ~Three() {--count;}
-};
-
-int Three::count = 0;
-
-template <class Alloc>
-void test()
-{
- int const bad = -1;
- {
- std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc());
- assert(Zero::count == 1);
- }
- assert(Zero::count == 0);
- {
- int const i = 42;
- std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i);
- assert(One::count == 1);
- assert(p->value == i);
- }
- assert(One::count == 0);
- {
- int const i = 42;
- std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad);
- assert(Two::count == 1);
- assert(p->value == i);
- }
- assert(Two::count == 0);
- {
- int const i = 42;
- std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad);
- assert(Three::count == 1);
- assert(p->value == i);
- }
- assert(Three::count == 0);
-}
-
-int main(int, char**)
-{
- {
- int i = 67;
- int const bad = -1;
- std::shared_ptr<Two> p = std::allocate_shared<Two>(test_allocator<Two>(54), i, bad);
- assert(test_allocator<Two>::alloc_count == 1);
- assert(Two::count == 1);
- assert(p->value == 67);
- }
- assert(Two::count == 0);
- assert(test_allocator<Two>::alloc_count == 0);
-
- test<bare_allocator<void> >();
-#if TEST_STD_VER >= 11
- test<min_allocator<void> >();
-#endif
-
- return 0;
-}
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 5228fab2e70..fd23fc4383f 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -14,6 +14,7 @@
#include <cstddef>
#include <cassert>
#include <climits>
+#include <memory>
#include "test_macros.h"
@@ -190,11 +191,6 @@ struct cpp03_overload_allocator : bare_allocator<T>
};
template <class T> bool cpp03_overload_allocator<T>::construct_called = false;
-
-#if TEST_STD_VER >= 11
-
-#include <memory>
-
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>;
@@ -462,6 +458,4 @@ public:
friend bool operator!=(explicit_allocator x, explicit_allocator y) {return !(x == y);}
};
-#endif // TEST_STD_VER >= 11
-
#endif // MIN_ALLOCATOR_H
OpenPOWER on IntegriCloud