From 4658842aa8c05227f9f0342d891ce5b1b49d4bab Mon Sep 17 00:00:00 2001 From: redi Date: Fri, 13 Jun 2014 11:59:22 +0000 Subject: 2014-06-13 Jonathan Wakely Backport from mainline PR libstdc++/60326 * include/std/type_traits (__make_unsigned, __make_signed): Define specializations for wchar_t, char16_t and char32_t. * testsuite/20_util/make_signed/requirements/typedefs-4.cc: New. * testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: Correct test for make_unsigned. * testsuite/20_util/make_unsigned/requirements/typedefs-2.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. Backport from mainline PR libstdc++/61269 * include/std/type_traits: Move include outside namespace std. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error. * 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/branches/gcc-4_9-branch@211636 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 26 +++++++++++++++++ libstdc++-v3/include/std/type_traits | 33 ++++++++++++++++++++++ .../20_util/declval/requirements/1_neg.cc | 2 +- .../20_util/make_signed/requirements/typedefs-4.cc | 33 ++++++++++++++++++++++ .../make_signed/requirements/typedefs_neg.cc | 4 +-- .../make_unsigned/requirements/typedefs-1.cc | 2 +- .../make_unsigned/requirements/typedefs-2.cc | 2 +- .../make_unsigned/requirements/typedefs_neg.cc | 4 +-- 8 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-4.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 762839b7b06..58ad18791cc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,29 @@ +2014-06-13 Jonathan Wakely + + Backport from mainline + PR libstdc++/60326 + * include/std/type_traits (__make_unsigned, __make_signed): Define + specializations for wchar_t, char16_t and char32_t. + * testsuite/20_util/make_signed/requirements/typedefs-4.cc: New. + * testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: Correct + test for make_unsigned. + * testsuite/20_util/make_unsigned/requirements/typedefs-2.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. + + Backport from mainline + PR libstdc++/61269 + * include/std/type_traits: Move include outside namespace std. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + 2014-06-07 Ed Smith-Rowland <3dw4rd@verizon.net> Backport from mainline diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 4b434a6025b..1ff2e625a73 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -37,6 +37,18 @@ #include +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +# if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__) +namespace std +{ + typedef __UINT_LEAST16_TYPE__ uint_least16_t; + typedef __UINT_LEAST32_TYPE__ uint_least32_t; +} +# else +# include +# endif +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -1583,6 +1595,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __make_unsigned { typedef unsigned long long __type; }; +#if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__) + template<> + struct __make_unsigned : __make_unsigned<__WCHAR_TYPE__> + { }; +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) template<> struct __make_unsigned<__int128> @@ -1665,6 +1683,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __make_signed { typedef signed long long __type; }; +#if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__) + template<> + struct __make_signed : __make_signed<__WCHAR_TYPE__> + { }; +#endif + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + template<> + struct __make_signed : __make_signed + { }; + template<> + struct __make_signed : __make_signed + { }; +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) template<> struct __make_signed 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 a744d832637..04e6b711906 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 *-*-* } 2003 } +// { dg-error "static assertion failed" "" { target *-*-* } 2036 } #include diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-4.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-4.cc new file mode 100644 index 00000000000..4950e5470cd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// { dg-require-cstdint "" } + +// Copyright (C) 2014 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 + +// libstdc++/60326 + +using namespace std; +#ifdef _GLIBCXX_USE_WCHAR_T +using wchar_signed = make_signed::type; +using wchar_unsigned = make_unsigned::type; +static_assert( !is_same::value, "wchar_t" ); +#endif +static_assert( is_signed::type>::value, "char16_t"); +static_assert( is_signed::type>::value, "char32_t"); 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 9f155ea92e2..d711546050d 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 *-*-* } 1714 } -// { dg-error "declaration of" "" { target *-*-* } 1678 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1747 } +// { dg-error "declaration of" "" { target *-*-* } 1711 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc index f07cf4a621b..a893ede133d 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc @@ -49,7 +49,7 @@ void test01() #ifdef _GLIBCXX_USE_WCHAR_T typedef make_unsigned::type test23_type; - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); #endif // Chapter 48, chapter 20. Smallest rank such that new unsigned type 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 index 8997fb7d812..637b0c7ca56 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc @@ -50,7 +50,7 @@ void test01() #ifdef _GLIBCXX_USE_WCHAR_T typedef make_unsigned::type test23_type; - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); #endif typedef make_unsigned::type test24_type; 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 57a5c616714..c77205be01d 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 *-*-* } 1632 } -// { dg-error "declaration of" "" { target *-*-* } 1596 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1650 } +// { dg-error "declaration of" "" { target *-*-* } 1614 } -- cgit v1.2.1