From aa940ab5d56c7a7f98f6a39e71c1b8fc26839c89 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 2 May 2013 11:00:26 +0000 Subject: [PATCH] type_traits (is_null_pointer): Add. 2013-05-02 Paolo Carlini * 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. From-SVN: r198516 --- libstdc++-v3/ChangeLog | 17 ++++++ libstdc++-v3/include/std/type_traits | 19 ++++-- .../20_util/declval/requirements/1_neg.cc | 2 +- .../requirements/explicit_instantiation.cc | 30 ++++++++++ .../is_null_pointer/requirements/typedefs.cc | 36 +++++++++++ .../20_util/is_null_pointer/value.cc | 60 +++++++++++++++++++ .../make_signed/requirements/typedefs_neg.cc | 4 +- .../requirements/typedefs_neg.cc | 4 +- 8 files changed, 161 insertions(+), 11 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dbc15fcbc1c..b57163e5289 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2013-05-02 Paolo Carlini + + * 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 * include/c_global/cstdio: Add comment about LWG 2249. 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 - struct __is_nullptr_t_helper + struct __is_null_pointer_helper : public false_type { }; template<> - struct __is_nullptr_t_helper + struct __is_null_pointer_helper : public true_type { }; - // __is_nullptr_t (extension). + /// is_null_pointer (LWG 2247). + template + struct is_null_pointer + : public __is_null_pointer_helper::type>::type + { }; + + /// __is_nullptr_t (extension). template struct __is_nullptr_t - : public __is_nullptr_t_helper::type>::type + : public is_null_pointer<_Tp> { }; // Composite type categories. @@ -433,7 +439,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_fundamental template struct is_fundamental - : public __or_, is_void<_Tp>, __is_nullptr_t<_Tp>>::type + : public __or_, is_void<_Tp>, + is_null_pointer<_Tp>>::type { }; /// is_object @@ -450,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_scalar : public __or_, 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 // . -// { dg-error "static assertion failed" "" { target *-*-* } 1852 } +// { dg-error "static assertion failed" "" { target *-*-* } 1859 } #include 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 + +// 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_null_pointer; +} 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 +// +// 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_null_pointer 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 +// +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_null_pointer; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(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 }