Commit f263981a by Paolo Carlini

[multiple changes]

2011-05-19  Daniel Krugler  <daniel.kruegler@googlemail.com>

	* testsuite/util/testsuite_tr1.h: Add test classes.
	* testsuite/20_util/is_nothrow_assignable/value.cc: Add.

2011-05-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/type_traits (is_assignable, is_copy_assignable,
	is_move_assignable, is_nothrow_assignable, is_nothrow_copy_assignable,
	is_nothrow_move_assignable): Add; minor tweaks elsewhere.
	(has_nothrow_copy_assign): Remove.
	* testsuite/util/testsuite_tr1.h: Add test classes.
	* testsuite/20_util/is_assignable/requirements/typedefs.cc: Add.
	* testsuite/20_util/is_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_nothrow_assignable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_assignable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_move_assignable/value.cc: Likewise.
	* testsuite/20_util/is_move_assignable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_move_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_copy_assignable/value.cc: Likewise.
	* testsuite/20_util/is_copy_assignable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_copy_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_nothrow_move_assignable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_move_assignable/requirements/
	typedefs.cc: Likewise.
	* testsuite/20_util/is_nothrow_move_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/is_nothrow_copy_assignable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_copy_assignable/requirements/
	typedefs.cc: Likewise.
	* testsuite/20_util/is_nothrow_copy_assignable/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
	dg-error line numbers.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.

From-SVN: r173899
parent 5fea7e8b
2011-05-19 Daniel Krugler <daniel.kruegler@googlemail.com>
* testsuite/util/testsuite_tr1.h: Add test classes.
* testsuite/20_util/is_nothrow_assignable/value.cc: Add.
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (is_assignable, is_copy_assignable,
is_move_assignable, is_nothrow_assignable, is_nothrow_copy_assignable,
is_nothrow_move_assignable): Add; minor tweaks elsewhere.
(has_nothrow_copy_assign): Remove.
* testsuite/util/testsuite_tr1.h: Add test classes.
* testsuite/20_util/is_assignable/requirements/typedefs.cc: Add.
* testsuite/20_util/is_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_nothrow_assignable/value.cc: Likewise.
* testsuite/20_util/is_nothrow_assignable/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_nothrow_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_move_assignable/value.cc: Likewise.
* testsuite/20_util/is_move_assignable/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_move_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_copy_assignable/value.cc: Likewise.
* testsuite/20_util/is_copy_assignable/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_copy_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_nothrow_move_assignable/value.cc: Likewise.
* testsuite/20_util/is_nothrow_move_assignable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_nothrow_move_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_nothrow_copy_assignable/value.cc: Likewise.
* testsuite/20_util/is_nothrow_copy_assignable/requirements/
typedefs.cc: Likewise.
* testsuite/20_util/is_nothrow_copy_assignable/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
dg-error line numbers.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
2011-05-18 Jonathan Wakely <jwakely.gcc@gmail.com> 2011-05-18 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr_base.h: Use noexcept. Define special member * include/bits/shared_ptr_base.h: Use noexcept. Define special member
......
...@@ -988,10 +988,110 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -988,10 +988,110 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public __is_nothrow_move_constructible_impl<_Tp> : public __is_nothrow_move_constructible_impl<_Tp>
{ }; { };
/// has_nothrow_copy_assign template<typename _Tp, typename _Up>
class __is_assignable_helper
: public __sfinae_types
{
template<typename _Tp1, typename _Up1>
static decltype(declval<_Tp1>() = declval<_Up1>(), __one())
__test(int);
template<typename, typename>
static __two __test(...);
public:
static constexpr bool value = sizeof(__test<_Tp, _Up>(0)) == 1;
};
/// is_assignable
template<typename _Tp, typename _Up>
struct is_assignable
: public integral_constant<bool,
__is_assignable_helper<_Tp, _Up>::value>
{ };
template<typename _Tp, bool = is_void<_Tp>::value>
struct __is_copy_assignable_impl;
template<typename _Tp>
struct __is_copy_assignable_impl<_Tp, true>
: public false_type { };
template<typename _Tp>
struct __is_copy_assignable_impl<_Tp, false>
: public is_assignable<_Tp&, const _Tp&&>
{ };
/// is_copy_assignable
template<typename _Tp>
struct is_copy_assignable
: public __is_copy_assignable_impl<_Tp>
{ };
template<typename _Tp, bool = is_void<_Tp>::value>
struct __is_move_assignable_impl;
template<typename _Tp>
struct __is_move_assignable_impl<_Tp, true>
: public false_type { };
template<typename _Tp>
struct __is_move_assignable_impl<_Tp, false>
: public is_assignable<_Tp&, _Tp&&>
{ };
/// is_move_assignable
template<typename _Tp>
struct is_move_assignable
: public __is_move_assignable_impl<_Tp>
{ };
template<typename _Tp, typename _Up>
struct __is_nt_assignable_impl
: public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
{ };
/// is_nothrow_assignable
template<typename _Tp, typename _Up>
struct is_nothrow_assignable
: public __and_<is_assignable<_Tp, _Up>,
__is_nt_assignable_impl<_Tp, _Up>>::type
{ };
template<typename _Tp, bool = is_void<_Tp>::value>
struct __is_nt_copy_assignable_impl;
template<typename _Tp>
struct __is_nt_copy_assignable_impl<_Tp, true>
: public false_type { };
template<typename _Tp>
struct __is_nt_copy_assignable_impl<_Tp, false>
: public is_nothrow_assignable<_Tp&, const _Tp&&>
{ };
/// is_nothrow_copy_assignable
template<typename _Tp>
struct is_nothrow_copy_assignable
: public __is_nt_copy_assignable_impl<_Tp>
{ };
template<typename _Tp, bool = is_void<_Tp>::value>
struct __is_nt_move_assignable_impl;
template<typename _Tp>
struct __is_nt_move_assignable_impl<_Tp, true>
: public false_type { };
template<typename _Tp>
struct __is_nt_move_assignable_impl<_Tp, false>
: public is_nothrow_assignable<_Tp&, _Tp&&>
{ };
/// is_nothrow_move_assignable
template<typename _Tp> template<typename _Tp>
struct has_nothrow_copy_assign struct is_nothrow_move_assignable
: public integral_constant<bool, __has_nothrow_assign(_Tp)> : public __is_nt_move_assignable_impl<_Tp>
{ }; { };
/// has_trivial_default_constructor /// has_trivial_default_constructor
...@@ -1086,7 +1186,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1086,7 +1186,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool = __or_<is_void<_From>, is_function<_To>, bool = __or_<is_void<_From>, is_function<_To>,
is_array<_To>>::value> is_array<_To>>::value>
struct __is_convertible_helper struct __is_convertible_helper
{ static const bool __value = is_void<_To>::value; }; { static constexpr bool value = is_void<_To>::value; };
template<typename _From, typename _To> template<typename _From, typename _To>
class __is_convertible_helper<_From, _To, false> class __is_convertible_helper<_From, _To, false>
...@@ -1103,14 +1203,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1103,14 +1203,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static __two __test(...); static __two __test(...);
public: public:
static const bool __value = sizeof(__test<_From, _To>(0)) == 1; static constexpr bool value = sizeof(__test<_From, _To>(0)) == 1;
}; };
/// is_convertible /// is_convertible
template<typename _From, typename _To> template<typename _From, typename _To>
struct is_convertible struct is_convertible
: public integral_constant<bool, : public integral_constant<bool,
__is_convertible_helper<_From, _To>::__value> __is_convertible_helper<_From, _To>::value>
{ }; { };
/// is_explicitly_convertible /// is_explicitly_convertible
...@@ -1729,7 +1829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1729,7 +1829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static __two __test(...); \ static __two __test(...); \
\ \
public: \ public: \
static const bool value = sizeof(__test<_Tp>(0)) == 1; \ static constexpr bool value = sizeof(__test<_Tp>(0)) == 1; \
}; \ }; \
\ \
template<typename _Tp> \ template<typename _Tp> \
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,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-error "static assertion failed" "" { target *-*-* } 1615 } // { dg-error "static assertion failed" "" { target *-*-* } 1715 }
#include <utility> #include <utility>
......
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2011 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/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
namespace std
{
typedef short test_type;
template struct is_assignable<test_type, test_type>;
}
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> // { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// //
// Copyright (C) 2010 Free Software Foundation, Inc. // Copyright (C) 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -23,12 +25,10 @@ ...@@ -23,12 +25,10 @@
#include <type_traits> #include <type_traits>
// { dg-do compile }
void test01() void test01()
{ {
// Check for required typedefs // Check for required typedefs
typedef std::has_nothrow_copy_assign<int> test_type; typedef std::is_assignable<int, int> test_type;
typedef test_type::value_type value_type; typedef test_type::value_type value_type;
typedef test_type::type type; typedef test_type::type type;
typedef test_type::type::value_type type_value_type; typedef test_type::type::value_type type_value_type;
......
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2011 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/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
namespace std
{
typedef short test_type;
template struct is_copy_assignable<test_type>;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::is_copy_assignable<int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
#include <type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::is_copy_assignable;
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_copy_assignable, int>(true)) );
VERIFY( (test_property<is_copy_assignable, float>(true)) );
VERIFY( (test_property<is_copy_assignable, EnumType>(true)) );
VERIFY( (test_property<is_copy_assignable, int*>(true)) );
VERIFY( (test_property<is_copy_assignable, int(*)(int)>(true)) );
VERIFY( (test_property<is_copy_assignable, int (ClassType::*)>(true)) );
VERIFY( (test_property<is_copy_assignable,
int (ClassType::*) (int)>(true)) );
VERIFY( (test_property<is_copy_assignable, NoexceptCopyAssignClass>(true)) );
VERIFY( (test_property<is_copy_assignable, ExceptCopyAssignClass>(true)) );
// Negative tests.
VERIFY( (test_property<is_copy_assignable, void>(false)) );
VERIFY( (test_property<is_copy_assignable, int[2]>(false)) );
VERIFY( (test_property<is_copy_assignable, float[][3]>(false)) );
VERIFY( (test_property<is_copy_assignable, EnumType[2][3][4]>(false)) );
VERIFY( (test_property<is_copy_assignable, int*[3]>(false)) );
VERIFY( (test_property<is_copy_assignable, int(*[][2])(int)>(false)) );
VERIFY( (test_property<is_copy_assignable,
int (ClassType::*[2][3])>(false)) );
VERIFY( (test_property<is_copy_assignable,
int (ClassType::*[][2][3]) (int)>(false)) );
VERIFY( (test_property<is_copy_assignable, NoexceptMoveAssignClass>(false)) );
VERIFY( (test_property<is_copy_assignable, ExceptMoveAssignClass>(false)) );
VERIFY( (test_property<is_copy_assignable, DeletedCopyAssignClass>(false)) );
VERIFY( (test_property<is_copy_assignable, DeletedMoveAssignClass>(false)) );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2011 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/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
namespace std
{
typedef short test_type;
template struct is_move_assignable<test_type>;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::is_move_assignable<int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
#include <type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::is_move_assignable;
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_move_assignable, int>(true)) );
VERIFY( (test_property<is_move_assignable, float>(true)) );
VERIFY( (test_property<is_move_assignable, EnumType>(true)) );
VERIFY( (test_property<is_move_assignable, int*>(true)) );
VERIFY( (test_property<is_move_assignable, int(*)(int)>(true)) );
VERIFY( (test_property<is_move_assignable, int (ClassType::*)>(true)) );
VERIFY( (test_property<is_move_assignable,
int (ClassType::*) (int)>(true)) );
VERIFY( (test_property<is_move_assignable, NoexceptMoveAssignClass>(true)) );
VERIFY( (test_property<is_move_assignable, ExceptMoveAssignClass>(true)) );
VERIFY( (test_property<is_move_assignable, NoexceptCopyAssignClass>(true)) );
VERIFY( (test_property<is_move_assignable, ExceptCopyAssignClass>(true)) );
// Negative tests.
VERIFY( (test_property<is_move_assignable, void>(false)) );
VERIFY( (test_property<is_move_assignable, int[2]>(false)) );
VERIFY( (test_property<is_move_assignable, float[][3]>(false)) );
VERIFY( (test_property<is_move_assignable, EnumType[2][3][4]>(false)) );
VERIFY( (test_property<is_move_assignable, int*[3]>(false)) );
VERIFY( (test_property<is_move_assignable, int(*[][2])(int)>(false)) );
VERIFY( (test_property<is_move_assignable,
int (ClassType::*[2][3])>(false)) );
VERIFY( (test_property<is_move_assignable,
int (ClassType::*[][2][3]) (int)>(false)) );
VERIFY( (test_property<is_move_assignable, DeletedCopyAssignClass>(false)) );
VERIFY( (test_property<is_move_assignable, DeletedMoveAssignClass>(false)) );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2011 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/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
namespace std
{
typedef short test_type;
template struct is_nothrow_assignable<test_type, test_type>;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
void test01()
{
// Check for required typedefs
typedef std::is_nothrow_assignable<int, int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> // 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// //
// Copyright (C) 2010 Free Software Foundation, Inc. // Copyright (C) 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -25,29 +25,30 @@ ...@@ -25,29 +25,30 @@
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
using std::has_nothrow_copy_assign; using std::is_nothrow_assignable;
using namespace __gnu_test; using namespace __gnu_test;
VERIFY( (test_property<has_nothrow_copy_assign, int>(true)) ); // Positive tests.
VERIFY( (test_property<has_nothrow_copy_assign, float>(true)) ); VERIFY( (test_relationship<is_nothrow_assignable, int&, int>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, EnumType>(true)) ); VERIFY( (test_relationship<is_nothrow_assignable, int&, const int>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, int*>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, int(*)(int)>(true)) ); VERIFY( (test_relationship<is_nothrow_assignable,
VERIFY( (test_property<has_nothrow_copy_assign, int (ClassType::*)>(true)) ); NoexceptCopyAssignClass&, const NoexceptCopyAssignClass&>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, VERIFY( (test_relationship<is_nothrow_assignable,
int (ClassType::*) (int)>(true)) ); NoexceptMoveAssignClass&, NoexceptMoveAssignClass&&>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, int[2]>(true)) ); VERIFY( (test_relationship<is_nothrow_assignable,
VERIFY( (test_property<has_nothrow_copy_assign, float[][3]>(true)) ); NoexceptCopyAssignClass&, NoexceptCopyAssignClass&&>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, EnumType[2][3][4]>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, int*[3]>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign, int(*[][2])(int)>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign,
int (ClassType::*[2][3])>(true)) );
VERIFY( (test_property<has_nothrow_copy_assign,
int (ClassType::*[][2][3]) (int)>(true)) );
// Negative tests. // Negative tests.
VERIFY( (test_property<has_nothrow_copy_assign, void>(false)) ); VERIFY( (test_relationship<is_nothrow_assignable, int, int>(false)) );
VERIFY( (test_relationship<is_nothrow_assignable, int, const int>(false)) );
VERIFY( (test_relationship<is_nothrow_assignable,
ExceptCopyAssignClass&, const ExceptCopyAssignClass&>(false)) );
VERIFY( (test_relationship<is_nothrow_assignable,
ExceptMoveAssignClass&, ExceptMoveAssignClass&&>(false)) );
VERIFY( (test_relationship<is_nothrow_assignable,
NoexceptMoveAssignClass&, const NoexceptMoveAssignClass&>(false)) );
} }
int main() int main()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// { dg-do compile } // { dg-do compile }
// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> // 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 Free Software Foundation, Inc. // Copyright (C) 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,5 +26,5 @@ ...@@ -26,5 +26,5 @@
namespace std namespace std
{ {
typedef short test_type; typedef short test_type;
template struct has_nothrow_copy_assign<test_type>; template struct is_nothrow_copy_assignable<test_type>;
} }
// { dg-options "-std=gnu++0x" }
// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010, 2011 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/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::is_nothrow_copy_assignable<int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
// { dg-options "-std=gnu++0x" }
// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010, 2011 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/>.
#include <type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::is_nothrow_copy_assignable;
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_nothrow_copy_assignable, int>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable, float>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable, EnumType>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable, int*>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable, int(*)(int)>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
int (ClassType::*)>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
int (ClassType::*) (int)>(true)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
NoexceptCopyAssignClass>(true)) );
// Negative tests.
VERIFY( (test_property<is_nothrow_copy_assignable, void>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable, int[2]>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable, float[][3]>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
EnumType[2][3][4]>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable, int*[3]>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
int(*[][2])(int)>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
int (ClassType::*[2][3])>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
int (ClassType::*[][2][3]) (int)>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
ExceptCopyAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
NoexceptMoveAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
ExceptMoveAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
DeletedCopyAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_copy_assignable,
DeletedMoveAssignClass>(false)) );
}
int main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2011 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/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
namespace std
{
typedef short test_type;
template struct is_nothrow_move_assignable<test_type>;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::is_nothrow_move_assignable<int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
// { dg-options "-std=gnu++0x" }
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2011 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/>.
#include <type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::is_nothrow_move_assignable;
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_nothrow_move_assignable, int>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable, float>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable, EnumType>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable, int*>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable, int(*)(int)>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable,
int (ClassType::*)>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable,
int (ClassType::*) (int)>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable,
NoexceptMoveAssignClass>(true)) );
VERIFY( (test_property<is_nothrow_move_assignable,
NoexceptCopyAssignClass>(true)) );
// Negative tests.
VERIFY( (test_property<is_nothrow_move_assignable, void>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable, int[2]>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable, float[][3]>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
EnumType[2][3][4]>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable, int*[3]>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
int(*[][2])(int)>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
int (ClassType::*[2][3])>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
int (ClassType::*[][2][3]) (int)>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
ExceptMoveAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
ExceptCopyAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
DeletedMoveAssignClass>(false)) );
VERIFY( (test_property<is_nothrow_move_assignable,
DeletedCopyAssignClass>(false)) );
}
int main()
{
test01();
return 0;
}
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 } // { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1401 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1501 }
// { dg-error "declaration of" "" { target *-*-* } 1365 } // { dg-error "declaration of" "" { target *-*-* } 1465 }
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 } // { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1325 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1425 }
// { dg-error "declaration of" "" { target *-*-* } 1289 } // { dg-error "declaration of" "" { target *-*-* } 1389 }
...@@ -204,6 +204,42 @@ namespace __gnu_test ...@@ -204,6 +204,42 @@ namespace __gnu_test
{ {
ExceptMoveConsClass(ExceptMoveConsClass&&) noexcept(false); ExceptMoveConsClass(ExceptMoveConsClass&&) noexcept(false);
}; };
struct NoexceptCopyAssignClass
{
NoexceptCopyAssignClass&
operator=(const NoexceptCopyAssignClass&) noexcept(true);
};
struct ExceptCopyAssignClass
{
ExceptCopyAssignClass&
operator=(const ExceptCopyAssignClass&) noexcept(false);
};
struct NoexceptMoveAssignClass
{
NoexceptMoveAssignClass&
operator=(NoexceptMoveAssignClass&&) noexcept(true);
};
struct ExceptMoveAssignClass
{
ExceptMoveAssignClass&
operator=(ExceptMoveAssignClass&&) noexcept(false);
};
struct DeletedCopyAssignClass
{
DeletedCopyAssignClass&
operator=(const DeletedCopyAssignClass&) = delete;
};
struct DeletedMoveAssignClass
{
DeletedMoveAssignClass&
operator=(DeletedMoveAssignClass&&) = delete;
};
#endif #endif
struct NType // neither trivial nor standard-layout struct NType // neither trivial nor standard-layout
...@@ -450,6 +486,180 @@ namespace __gnu_test ...@@ -450,6 +486,180 @@ namespace __gnu_test
UnusualCopy(UnusualCopy&); UnusualCopy(UnusualCopy&);
}; };
} }
namespace assign
{
struct Empty {};
struct B { int i; B(){} };
struct D : B {};
enum E { ee1 };
enum E2 { ee2 };
enum class SE { e1 };
enum class SE2 { e2 };
enum OpE : int;
enum class OpSE : bool;
union U { int i; Empty b; };
union UAssignAll
{
bool b;
char c;
template<class T>
void operator=(T&&);
};
union UDelAssignAll
{
bool b;
char c;
template<class T>
void operator=(T&&) = delete;
};
struct Abstract
{
virtual ~Abstract() = 0;
};
struct AbstractDelDtor
{
~AbstractDelDtor() = delete;
virtual void foo() = 0;
};
struct Ukn;
template<class To>
struct ImplicitTo
{
operator To();
};
template<class To>
struct ExplicitTo
{
explicit operator To();
};
template<class To>
struct DelImplicitTo
{
operator To() = delete;
};
template<class To>
struct DelExplicitTo
{
explicit operator To() = delete;
};
struct Ellipsis
{
Ellipsis(...){}
};
struct DelEllipsis
{
DelEllipsis(...) = delete;
};
struct Any
{
template<class T>
Any(T&&){}
};
struct nAny
{
template<class... T>
nAny(T&&...){}
};
struct DelnAny
{
template<class... T>
DelnAny(T&&...) = delete;
};
template<class... Args>
struct FromArgs
{
FromArgs(Args...);
};
template<class... Args>
struct DelFromArgs
{
DelFromArgs(Args...) = delete;
};
struct DelDef
{
DelDef() = delete;
};
struct DelCopy
{
DelCopy(const DelCopy&) = delete;
};
struct DelDtor
{
DelDtor() = default;
DelDtor(const DelDtor&) = default;
DelDtor(DelDtor&&) = default;
DelDtor(int);
DelDtor(int, B, U);
~DelDtor() = delete;
};
struct Nontrivial
{
Nontrivial();
Nontrivial(const Nontrivial&);
Nontrivial& operator=(const Nontrivial&);
~Nontrivial();
};
union NontrivialUnion
{
int i;
Nontrivial n;
};
struct UnusualCopy
{
UnusualCopy(UnusualCopy&);
};
struct AnyAssign
{
template<class T>
void operator=(T&&);
};
struct DelAnyAssign
{
template<class T>
void operator=(T&&) = delete;
};
struct DelCopyAssign
{
DelCopyAssign& operator=(const DelCopyAssign&) = delete;
DelCopyAssign& operator=(DelCopyAssign&&) = default;
};
struct MO
{
MO(MO&&) = default;
MO& operator=(MO&&) = default;
};
}
#endif #endif
} // namespace __gnu_test } // namespace __gnu_test
......
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