Commit 50875e80 by Jonathan Wakely Committed by Jonathan Wakely

noexcept.cc: Change to compile-only test.

	* testsuite/23_containers/forward_list/allocator/noexcept.cc: Change
	to compile-only test. Adjust swap overload to handle rebound
	allocators.
	* testsuite/23_containers/map/allocator/noexcept.cc: Likewise.
	* testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise.
	* testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise.
	* testsuite/23_containers/set/allocator/noexcept.cc: Likewise.
	* testsuite/23_containers/unordered_map/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/vector/allocator/noexcept.cc: Likewise.
	* testsuite/23_containers/vector/allocator/swap.cc: Add elements
	before swapping.

From-SVN: r205056
parent fefa31b5
2013-11-19 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/23_containers/forward_list/allocator/noexcept.cc: Change
to compile-only test. Adjust swap overload to handle rebound
allocators.
* testsuite/23_containers/map/allocator/noexcept.cc: Likewise.
* testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise.
* testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise.
* testsuite/23_containers/set/allocator/noexcept.cc: Likewise.
* testsuite/23_containers/unordered_map/allocator/noexcept.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/allocator/noexcept.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/allocator/noexcept.cc:
Likewise.
* testsuite/23_containers/unordered_set/allocator/noexcept.cc:
Likewise.
* testsuite/23_containers/vector/allocator/noexcept.cc: Likewise.
* testsuite/23_containers/vector/allocator/swap.cc: Add elements
before swapping.
2013-11-19 Paolo Carlini <paolo.carlini@oracle.com> 2013-11-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/experimental/string_view (_S_max_size): Remove. * include/experimental/string_view (_S_max_size): Remove.
......
...@@ -15,23 +15,21 @@ ...@@ -15,23 +15,21 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
#include <forward_list> #include <forward_list>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -64,13 +62,5 @@ void test03() ...@@ -64,13 +62,5 @@ void test03()
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
// static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
}
int main()
{
test01();
test02();
test03();
return 0;
} }
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++11" } // { dg-options "-std=gnu++11" }
#include <map> #include <map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -31,14 +31,11 @@ struct U { }; ...@@ -31,14 +31,11 @@ struct U { };
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<std::pair<const T, U>, true>& l, inline void
propagating_allocator<std::pair<const T, U>, true>& r) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
noexcept(false) noexcept(false)
{ { }
typedef uneq_allocator<std::pair<const T, U>> base_alloc;
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -73,11 +70,3 @@ void test03() ...@@ -73,11 +70,3 @@ void test03()
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
} }
int main()
{
test01();
test02();
test03();
return 0;
}
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++11" } // { dg-options "-std=gnu++11" }
#include <map> #include <map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -31,14 +31,11 @@ struct U { }; ...@@ -31,14 +31,11 @@ struct U { };
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<std::pair<const T, U>, true>& l, inline void
propagating_allocator<std::pair<const T, U>, true>& r) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
noexcept(false) noexcept(false)
{ { }
typedef uneq_allocator<std::pair<const T, U>> base_alloc;
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -73,11 +70,3 @@ void test03() ...@@ -73,11 +70,3 @@ void test03()
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
} }
int main()
{
test01();
test02();
test03();
return 0;
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++11" } // { dg-options "-std=gnu++11" }
#include <set> #include <set>
...@@ -29,14 +30,11 @@ using Cmp = std::less<T>; ...@@ -29,14 +30,11 @@ using Cmp = std::less<T>;
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, inline void
propagating_allocator<T, true>& r) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
noexcept(false) noexcept(false)
{ { }
typedef uneq_allocator<T> base_alloc;
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -71,11 +69,3 @@ void test03() ...@@ -71,11 +69,3 @@ void test03()
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
} }
int main()
{
test01();
test02();
test03();
return 0;
}
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++11" } // { dg-options "-std=gnu++11" }
#include <set> #include <set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -29,14 +29,11 @@ using Cmp = std::less<T>; ...@@ -29,14 +29,11 @@ using Cmp = std::less<T>;
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, inline void
propagating_allocator<T, true>& r) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
noexcept(false) noexcept(false)
{ { }
typedef uneq_allocator<T> base_alloc;
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -71,11 +68,3 @@ void test03() ...@@ -71,11 +68,3 @@ void test03()
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
} }
int main()
{
test01();
test02();
test03();
return 0;
}
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=c++11" } // { dg-options "-std=c++11" }
#include <unordered_map> #include <unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -37,13 +37,11 @@ struct equal_to ...@@ -37,13 +37,11 @@ struct equal_to
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -76,13 +74,5 @@ void test03() ...@@ -76,13 +74,5 @@ void test03()
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
// static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
}
int main()
{
test01();
test02();
test03();
return 0;
} }
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=c++11" } // { dg-options "-std=c++11" }
#include <unordered_map> #include <unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -37,13 +37,11 @@ struct equal_to ...@@ -37,13 +37,11 @@ struct equal_to
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -76,13 +74,5 @@ void test03() ...@@ -76,13 +74,5 @@ void test03()
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
// static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
}
int main()
{
test01();
test02();
test03();
return 0;
} }
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=c++11" } // { dg-options "-std=c++11" }
#include <unordered_set> #include <unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -37,13 +37,11 @@ struct equal_to ...@@ -37,13 +37,11 @@ struct equal_to
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -76,13 +74,5 @@ void test03() ...@@ -76,13 +74,5 @@ void test03()
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
// static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
}
int main()
{
test01();
test02();
test03();
return 0;
} }
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=c++11" } // { dg-options "-std=c++11" }
#include <unordered_set> #include <unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
...@@ -37,13 +37,11 @@ struct equal_to ...@@ -37,13 +37,11 @@ struct equal_to
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -76,13 +74,5 @@ void test03() ...@@ -76,13 +74,5 @@ void test03()
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
// static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
}
int main()
{
test01();
test02();
test03();
return 0;
} }
...@@ -15,23 +15,21 @@ ...@@ -15,23 +15,21 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
#include <vector> #include <vector>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
struct T { int i; }; struct T { int i; };
namespace __gnu_test namespace __gnu_test
{ {
inline void template<typename U>
swap(propagating_allocator<T, true>& l, propagating_allocator<T, true>& r) inline void
noexcept(false) swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r)
{ noexcept(false)
typedef uneq_allocator<T> base_alloc; { }
swap(static_cast<base_alloc&>(l), static_cast<base_alloc&>(r));
}
} }
using __gnu_test::propagating_allocator; using __gnu_test::propagating_allocator;
...@@ -66,11 +64,3 @@ void test03() ...@@ -66,11 +64,3 @@ void test03()
static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" );
static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" );
} }
int main()
{
test01();
test02();
test03();
return 0;
}
...@@ -64,7 +64,9 @@ void test02() ...@@ -64,7 +64,9 @@ void test02()
typedef propagating_allocator<T, true> alloc_type; typedef propagating_allocator<T, true> alloc_type;
typedef std::vector<T, alloc_type> test_type; typedef std::vector<T, alloc_type> test_type;
test_type v1(alloc_type(1)); test_type v1(alloc_type(1));
v1.push_back(T());
test_type v2(alloc_type(2)); test_type v2(alloc_type(2));
v2.push_back(T());
std::swap(v1, v2); std::swap(v1, v2);
VERIFY(2 == v1.get_allocator().get_personality()); VERIFY(2 == v1.get_allocator().get_personality());
VERIFY(1 == v2.get_allocator().get_personality()); VERIFY(1 == v2.get_allocator().get_personality());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment