diff options
| author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-07 15:29:57 +0000 |
|---|---|---|
| committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-07 15:29:57 +0000 |
| commit | 9293b324e70026ecb7ed8955bf0b6e410d213ca1 (patch) | |
| tree | 9518d4e7a62dfc1fc031eb8b35ad814f47f5a435 | |
| parent | 66d3a87b51bc320e59db2c0256338e004ce3d519 (diff) | |
| download | ppe42-gcc-9293b324e70026ecb7ed8955bf0b6e410d213ca1.tar.gz ppe42-gcc-9293b324e70026ecb7ed8955bf0b6e410d213ca1.zip | |
2007-05-07 Benjamin Kosnik <bkoz@redhat.com>
Howard Hinnant <hhinnant@apple.com>
* 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
| -rw-r--r-- | libstdc++-v3/ChangeLog | 17 | ||||
| -rw-r--r-- | libstdc++-v3/include/std/type_traits | 24 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc | 8 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc (renamed from libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc) | 0 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc | 68 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc (renamed from libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc) | 0 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc | 68 |
7 files changed, 169 insertions, 16 deletions
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 <bkoz@redhat.com> + Howard Hinnant <hhinnant@apple.com> + + * 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 <pcarlini@suse.de> * 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 index 826e47ed3e8..826e47ed3e8 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc +++ b/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 <bkoz@redhat.com> +// +// 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 <type_traits> +#include <testsuite_hooks.h> + +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<const int>::type test2_type; + VERIFY( (is_same<test2_type, const int>::value) ); + + typedef make_signed<const unsigned int>::type test21c_type; + VERIFY( (is_same<test21c_type, const signed int>::value) ); + + typedef make_signed<volatile unsigned int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile signed int>::value) ); + + typedef make_signed<const volatile unsigned int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile signed int>::value) ); + + typedef make_signed<const char>::type test22_type; + VERIFY( (is_same<test22_type, const signed char>::value) ); + + typedef make_signed<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile signed wchar_t>::value) ); + +#if 0 + // XXX + // When is_signed works for floating points types this should pass + typedef make_signed<volatile float>::type test24_type; + VERIFY( (is_same<test24_type, volatile int>::value) ); +#endif + + typedef make_signed<test_enum>::type test25_type; + VERIFY( (is_same<test25_type, short>::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 index b09d3e93aa4..b09d3e93aa4 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc +++ b/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 <bkoz@redhat.com> +// +// 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 <type_traits> +#include <testsuite_hooks.h> + +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<const unsigned int>::type test2_type; + VERIFY( (is_same<test2_type, const unsigned int>::value) ); + + typedef make_unsigned<const signed int>::type test21c_type; + VERIFY( (is_same<test21c_type, const unsigned int>::value) ); + + typedef make_unsigned<volatile signed int>::type test21v_type; + VERIFY( (is_same<test21v_type, volatile unsigned int>::value) ); + + typedef make_unsigned<const volatile signed int>::type test21cv_type; + VERIFY( (is_same<test21cv_type, const volatile unsigned int>::value) ); + + typedef make_unsigned<const char>::type test22_type; + VERIFY( (is_same<test22_type, const unsigned char>::value) ); + + typedef make_unsigned<volatile wchar_t>::type test23_type; + VERIFY( (is_same<test23_type, volatile unsigned wchar_t>::value) ); + +#if 0 + // XXX + // When is_unsigned works for floating points types this should pass + typedef make_unsigned<volatile float>::type test24_type; + VERIFY( (is_same<test24_type, volatile unsigned int>::value) ); +#endif + + typedef make_unsigned<test_enum>::type test25_type; + VERIFY( (is_same<test25_type, unsigned short>::value) ); +} + +int main() +{ + test01(); + return 0; +} |

