diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-07 15:01:33 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-07 15:01:33 +0000 |
commit | 7903c81247823e360dbbdcf0e27425b1a86a09ee (patch) | |
tree | 30850f33b00dc6cf6fb619896993a9ff8417f621 /libstdc++-v3/testsuite | |
parent | 0663474603e8cbf38cf8a560cfbbbe47b5f686da (diff) | |
download | gcc-7903c81247823e360dbbdcf0e27425b1a86a09ee.tar.gz |
Use std::addressof in insert iterators, allocators and promises
PR libstdc++/69105
PR libstdc++/69106
PR libstdc++/69114
* include/bits/stl_iterator.h (back_insert_iterator,
front_insert_iterator, insert_iterator): Use __addressof (LWG 2324).
* include/bits/uses_allocator.h (__use_alloc): Use __addressof.
* include/std/future (__future::base::_State_baseV2::__setter):
Likewise.
* include/std/scoped_allocator (__outermost): Likewise.
* testsuite/20_util/scoped_allocator/69114.cc: New.
* testsuite/20_util/uses_allocator/69114.cc: New.
* testsuite/30_threads/promise/69106.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232129 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc | 50 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc | 49 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/promise/69106.cc | 34 |
3 files changed, 133 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc new file mode 100644 index 00000000000..6890d187795 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// PR libstdc++/69114 + +#include <scoped_allocator> + +template<typename T> +struct Alloc +{ + using value_type = T; + + Alloc() = default; + + template<typename U> + Alloc(const Alloc<U>&) { } + + T* allocate(std::size_t); + void deallocate(T*, std::size_t); + + bool operator==(const Alloc&) const { return true; } + bool operator!=(const Alloc&) const { return false; } + + void operator&() = delete; +}; + +void +test01() +{ + using alloc_type = Alloc<std::pair<int, int>>; + std::scoped_allocator_adaptor<alloc_type> a; + a.construct(a.allocate(1)); +} diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc new file mode 100644 index 00000000000..0ab7ed33f15 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// PR libstdc++/69114 + +#include <tuple> + +template<typename T> +struct Alloc +{ + using value_type = T; + + Alloc() = default; + + template<typename U> + Alloc(const Alloc<U>&) { } + + T* allocate(std::size_t); + void deallocate(T*, std::size_t); + + bool operator==(const Alloc&) const { return true; } + bool operator!=(const Alloc&) const { return false; } + + void operator&() = delete; +}; + +void +test01() +{ + Alloc<int> a; + std::tuple<int> t(std::allocator_arg, a); +} diff --git a/libstdc++-v3/testsuite/30_threads/promise/69106.cc b/libstdc++-v3/testsuite/30_threads/promise/69106.cc new file mode 100644 index 00000000000..921ded13dea --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/promise/69106.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +#include <future> + +struct foo { + void operator&() const = delete; +}; + +void test01() +{ + std::promise<foo> p; + p.set_value(foo()); +} |