From: bkoz Date: Mon, 7 May 2007 15:29:57 +0000 (+0000) Subject: 2007-05-07 Benjamin Kosnik X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=9293b324e70026ecb7ed8955bf0b6e410d213ca1;p=pf3gnuchains%2Fgcc-fork.git 2007-05-07 Benjamin Kosnik Howard Hinnant * include/std/type_traits: (make_signed, make_unsigned): Adjust for enum sizes. * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Move to... * testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: ...here. * testsuite/20_util/make_unsigned/requirements/typedefs-2.cc: Add, compile with -funsigned-char -fshort-enums. * testsuite/20_util/make_signed/requirements/typedefs.cc: Move to... * testsuite/20_util/make_signed/requirements/typedefs-1.cc: ...here. * testsuite/20_util/make_signed/requirements/typedefs-2.cc: Add, compile with -funsigned-char -fshort-enums. * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Add a temporary xfail to this test for all platforms. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124500 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ec746b2802b..7a0a27cd685 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2007-05-07 Benjamin Kosnik + Howard Hinnant + + * include/std/type_traits: (make_signed, make_unsigned): Adjust + for enum sizes. + * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Move to... + * testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: ...here. + * testsuite/20_util/make_unsigned/requirements/typedefs-2.cc: Add, + compile with -funsigned-char -fshort-enums. + * testsuite/20_util/make_signed/requirements/typedefs.cc: Move to... + * testsuite/20_util/make_signed/requirements/typedefs-1.cc: ...here. + * testsuite/20_util/make_signed/requirements/typedefs-2.cc: Add, + compile with -funsigned-char -fshort-enums. + + * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: + Add a temporary xfail to this test for all platforms. + 2007-05-06 Paolo Carlini * include/std/complex: Add missing extern template declarations. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 0d7e85e5300..40191887d49 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -204,15 +204,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct __make_unsigned_selector<_Tp, false, false, true> { private: - // GNU enums start with sizeof int. - static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned int); - static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned long); - typedef conditional<__b2, unsigned long, unsigned long long> __cond; + // GNU enums start with sizeof short. + typedef unsigned short __smallest; + static const bool __b1 = sizeof(_Tp) <= sizeof(__smallest); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int); + typedef conditional<__b2, unsigned int, unsigned long> __cond; typedef typename __cond::type __cond_type; - typedef unsigned int __ui_type; public: - typedef typename conditional<__b1, __ui_type, __cond_type>::type __type; + typedef typename conditional<__b1, __smallest, __cond_type>::type __type; }; // Primary class template. @@ -301,15 +301,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct __make_signed_selector<_Tp, false, false, true> { private: - // GNU enums start with sizeof int. - static const bool __b1 = sizeof(_Tp) <= sizeof(signed int); - static const bool __b2 = sizeof(_Tp) <= sizeof(signed long); - typedef conditional<__b2, signed long, signed long long> __cond; + // GNU enums start with sizeof short. + typedef signed short __smallest; + static const bool __b1 = sizeof(_Tp) <= sizeof(__smallest); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed int); + typedef conditional<__b2, signed int, signed long> __cond; typedef typename __cond::type __cond_type; - typedef int __i_type; public: - typedef typename conditional<__b1, __i_type, __cond_type>::type __type; + typedef typename conditional<__b1, __smallest, __cond_type>::type __type; }; // Primary class template. diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc index 37c5a0346d1..baeb71e0072 100644 --- a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -30,8 +30,8 @@ namespace gnu using std::has_nothrow_copy; } -// { dg-error "has not been declared" "" { target *-*-* } 27 } -// { dg-error "has not been declared" "" { target *-*-* } 28 } -// { dg-error "has not been declared" "" { target *-*-* } 29 } -// { dg-error "has not been declared" "" { target *-*-* } 30 } +// { dg-error "has not been declared" "" { xfail *-*-* } 27 } +// { dg-error "has not been declared" "" { xfail *-*-* } 28 } +// { dg-error "has not been declared" "" { xfail *-*-* } 29 } +// { dg-error "has not been declared" "" { xfail *-*-* } 30 } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc similarity index 100% rename from libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc rename to libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc new file mode 100644 index 00000000000..3a820ace9eb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_signed works for floating points types this should pass + typedef make_signed::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_signed::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc similarity index 100% rename from libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc rename to libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc new file mode 100644 index 00000000000..9e5c64aff2c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_unsigned works for floating points types this should pass + typedef make_unsigned::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_unsigned::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +}