From 55ef7c2e762e7d4ff6a6327b5f12c370c2e8282c Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 29 Oct 2009 23:23:29 +0000 Subject: [PATCH] 2009-10-29 Paolo Carlini * include/std/type_traits (__is_int_or_cref): Remove. (__is_convertible_helper): Fix per C++0x and simplify (the hack to suppress warnings isn't necessary anymore). * testsuite/20_util/is_convertible/requirements/typedefs.cc: New. * testsuite/20_util/is_convertible/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_convertible/value.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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153728 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 14 +++ libstdc++-v3/include/std/type_traits | 26 +----- .../requirements/explicit_instantiation.cc | 31 +++++++ .../is_convertible/requirements/typedefs.cc | 36 ++++++++ .../testsuite/20_util/is_convertible/value.cc | 102 +++++++++++++++++++++ .../make_signed/requirements/typedefs_neg.cc | 6 +- .../make_unsigned/requirements/typedefs_neg.cc | 6 +- 7 files changed, 194 insertions(+), 27 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/value.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2f3f9dc..2929d5a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,19 @@ 2009-10-29 Paolo Carlini + * include/std/type_traits (__is_int_or_cref): Remove. + (__is_convertible_helper): Fix per C++0x and simplify (the hack to + suppress warnings isn't necessary anymore). + * testsuite/20_util/is_convertible/requirements/typedefs.cc: New. + * testsuite/20_util/is_convertible/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_convertible/value.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. + +2009-10-29 Paolo Carlini + * testsuite/20_util/pair/40925.cc: Minor comment fix. 2009-10-29 Paolo Carlini diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index dd26bb8..f5666bc 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -253,39 +253,23 @@ namespace std static const bool __value = sizeof(__test(__makeFrom())) == 1; }; - template - struct __is_int_or_cref - { - typedef typename remove_reference<_Tp>::type __rr_Tp; - static const bool __value = (is_integral<_Tp>::value - || (is_integral<__rr_Tp>::value - && is_const<__rr_Tp>::value - && !is_volatile<__rr_Tp>::value)); - }; - template::value || is_void<_To>::value - || is_function<_To>::value || is_array<_To>::value - // This special case is here only to avoid warnings. - || (is_floating_point::type>::value - && __is_int_or_cref<_To>::__value))> + || is_function<_To>::value || is_array<_To>::value)> struct __is_convertible_helper { - // "An imaginary lvalue of type From...". static const bool __value = (__is_convertible_simple::type, + add_rvalue_reference<_From>::type, _To>::__value); }; template struct __is_convertible_helper<_From, _To, true> - { static const bool __value = (is_void<_To>::value - || (__is_int_or_cref<_To>::__value - && !is_void<_From>::value)); }; + { static const bool __value = (is_void<_From>::value + && is_void<_To>::value); }; // XXX FIXME - // The C++0x specifications are different, see N2255. + // The C++0x specifications require front-end support, see N2255. /// is_convertible template struct is_convertible diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 0000000..646c4b2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini + +// Copyright (C) 2009 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_convertible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc new file mode 100644 index 0000000..1e8deb5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini +// +// Copyright (C) 2009 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 + +void test01() +{ + // Check for required typedefs + typedef std::is_convertible 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_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc new file mode 100644 index 0000000..6ec22d0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-10-29 Paolo Carlini +// +// Copyright (C) 2009 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_convertible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + + VERIFY( (test_relationship(true)) ); + + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + + // Negative tests. + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + // C++0x + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(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 3455462..5b129e8 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 @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009 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 @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 570 } -// { dg-error "declaration of" "" { target *-*-* } 532 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 554 } +// { dg-error "declaration of" "" { target *-*-* } 516 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } 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 3d3a10a..fc58ffe 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 @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009 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 @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 491 } -// { dg-error "declaration of" "" { target *-*-* } 453 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 475 } +// { dg-error "declaration of" "" { target *-*-* } 437 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } -- 2.7.4