OSDN Git Service

2007-05-07 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 May 2007 15:29:57 +0000 (15:29 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 May 2007 15:29:57 +0000 (15:29 +0000)
            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

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc [moved from libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc with 100% similarity]
libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc [moved from libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc with 100% similarity]
libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc [new file with mode: 0644]

index ec746b2..7a0a27c 100644 (file)
@@ -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.
index 0d7e85e..4019188 100644 (file)
@@ -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.
index 37c5a03..baeb71e 100644 (file)
@@ -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-2.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
new file mode 100644 (file)
index 0000000..3a820ac
--- /dev/null
@@ -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-2.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc
new file mode 100644 (file)
index 0000000..9e5c64a
--- /dev/null
@@ -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;
+}