aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2007-05-07 15:29:57 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2007-05-07 15:29:57 +0000
commitce2e63495d2873df275a1e38015d0b838e50a75b (patch)
tree9518d4e7a62dfc1fc031eb8b35ad814f47f5a435 /libstdc++-v3
parent4be1caf900da7480142d0c027a251b28d2af49a0 (diff)
downloadgcc-ce2e63495d2873df275a1e38015d0b838e50a75b.zip
gcc-ce2e63495d2873df275a1e38015d0b838e50a75b.tar.gz
gcc-ce2e63495d2873df275a1e38015d0b838e50a75b.tar.bz2
type_traits: (make_signed, make_unsigned): Adjust for enum sizes.
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. Co-Authored-By: Howard Hinnant <hhinnant@apple.com> From-SVN: r124500
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog17
-rw-r--r--libstdc++-v3/include/std/type_traits24
-rw-r--r--libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc8
-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.cc68
-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.cc68
7 files changed, 169 insertions, 16 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ec746b2..7a0a27c 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 0d7e85e..4019188 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 37c5a03..baeb71e 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 826e47e..826e47e 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 0000000..3a820ac
--- /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 b09d3e9..b09d3e9 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 0000000..9e5c64a
--- /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;
+}