diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-02 11:00:26 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-02 11:00:26 +0000 |
commit | 1ac9f544d33e508a80a1875e89f476ce12bcd572 (patch) | |
tree | 68543a79fb3702b37fd60ae9c575fc44dc782072 /libstdc++-v3 | |
parent | aba73ec6710a59f7e3dbd09cf7968d244324d2f1 (diff) | |
download | gcc-1ac9f544d33e508a80a1875e89f476ce12bcd572.tar.gz |
2013-05-02 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (is_null_pointer): Add.
(__is_nullptr_t): Implement in terms of the latter.
(is_fundamental, is_scalar): Adjust.
* testsuite/20_util/is_null_pointer/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/is_null_pointer/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_null_pointer/value.cc: Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198516 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
8 files changed, 161 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dbc15fcbc1c..b57163e5289 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,22 @@ 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> + * include/std/type_traits (is_null_pointer): Add. + (__is_nullptr_t): Implement in terms of the latter. + (is_fundamental, is_scalar): Adjust. + * testsuite/20_util/is_null_pointer/requirements/ + explicit_instantiation.cc: New. + * testsuite/20_util/is_null_pointer/requirements/typedefs.cc: + Likewise. + * testsuite/20_util/is_null_pointer/value.cc: Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error + line number. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + +2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> + * include/c_global/cstdio: Add comment about LWG 2249. * include/c_std/cstdio: Likewise. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 79a9b6ae690..a0a8327bec5 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -402,17 +402,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public true_type { }; template<typename> - struct __is_nullptr_t_helper + struct __is_null_pointer_helper : public false_type { }; template<> - struct __is_nullptr_t_helper<std::nullptr_t> + struct __is_null_pointer_helper<std::nullptr_t> : public true_type { }; - // __is_nullptr_t (extension). + /// is_null_pointer (LWG 2247). + template<typename _Tp> + struct is_null_pointer + : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type + { }; + + /// __is_nullptr_t (extension). template<typename _Tp> struct __is_nullptr_t - : public __is_nullptr_t_helper<typename remove_cv<_Tp>::type>::type + : public is_null_pointer<_Tp> { }; // Composite type categories. @@ -433,7 +439,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_fundamental template<typename _Tp> struct is_fundamental - : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, __is_nullptr_t<_Tp>>::type + : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, + is_null_pointer<_Tp>>::type { }; /// is_object @@ -450,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> struct is_scalar : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, - is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type + is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type { }; /// is_compound diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index 02347d1685e..ad821905a06 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 1852 } +// { dg-error "static assertion failed" "" { target *-*-* } 1859 } #include <utility> diff --git a/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..9df6719cf81 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2013 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_null_pointer<test_type>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc new file mode 100644 index 00000000000..057d9648544 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2013 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_null_pointer<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; +} diff --git a/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc b/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc new file mode 100644 index 00000000000..2bee73a6a0b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++11" } +// 2013-05-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2013 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_null_pointer; + using namespace __gnu_test; + + VERIFY( (test_category<is_null_pointer, std::nullptr_t>(true)) ); + + VERIFY( (test_category<is_null_pointer, int>(false)) ); + VERIFY( (test_category<is_null_pointer, float>(false)) ); + VERIFY( (test_category<is_null_pointer, EnumType>(false)) ); + VERIFY( (test_category<is_null_pointer, int*>(false)) ); + VERIFY( (test_category<is_null_pointer, int(*)(int)>(false)) ); + VERIFY( (test_category<is_null_pointer, int (ClassType::*)>(false)) ); + VERIFY( (test_category<is_null_pointer, int (ClassType::*) (int)>(false)) ); + VERIFY( (test_category<is_null_pointer, int[2]>(false)) ); + VERIFY( (test_category<is_null_pointer, float[][3]>(false)) ); + VERIFY( (test_category<is_null_pointer, EnumType[2][3][4]>(false)) ); + VERIFY( (test_category<is_null_pointer, int*[3]>(false)) ); + VERIFY( (test_category<is_null_pointer, int(*[][2])(int)>(false)) ); + VERIFY( (test_category<is_null_pointer, int (ClassType::*[2][3])>(false)) ); + VERIFY( (test_category<is_null_pointer, + int (ClassType::*[][2][3]) (int)>(false)) ); + VERIFY( (test_category<is_null_pointer, ClassType>(false)) ); + VERIFY( (test_category<is_null_pointer, PODType>(false)) ); + VERIFY( (test_category<is_null_pointer, void>(false)) ); + VERIFY( (test_category<is_null_pointer, NType>(false)) ); + VERIFY( (test_category<is_null_pointer, TType>(false)) ); + VERIFY( (test_category<is_null_pointer, SLType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index b2d5d770e63..077e32797a6 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1594 } -// { dg-error "declaration of" "" { target *-*-* } 1558 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 } +// { dg-error "declaration of" "" { target *-*-* } 1565 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 8980fe1ba8f..2bc1cbbad12 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1512 } -// { dg-error "declaration of" "" { target *-*-* } 1476 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 } +// { dg-error "declaration of" "" { target *-*-* } 1483 } |