This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] make_signed/unsigned floating_point fixes



Remove support for floating point types in make_signed/unsigned, as per specification and Howard's clarification.


tested x86/linux

-benjamin
2007-05-08  Benjamin Kosnik  <bkoz@redhat.com>

	* include/std/type_traits (make_signed): Remove specializations
	for floating point types.
	(make_unsigned): Same.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Fix.
	* testsuite/20_util/make_signed/requirements/typedefs-1.cc: Same.
	* testsuite/20_util/make_signed/requirements/typedefs-2.cc: Same.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
	* testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: Same.
	* testsuite/20_util/make_unsigned/requirements/typedefs-2.cc: Same.


Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 124542)
+++ include/std/type_traits	(working copy)
@@ -186,21 +186,6 @@
     };
 
   template<typename _Tp>
-    struct __make_unsigned_selector<_Tp, false, true, false>
-    {
-    private:
-      // GNU floating point types 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;
-      typedef typename __cond::type __cond_type;
-      typedef unsigned int __ui_type;
-
-    public:
-      typedef typename conditional<__b1, __ui_type, __cond_type>::type __type;
-    };
-
-  template<typename _Tp>
     struct __make_unsigned_selector<_Tp, false, false, true>
     {
     private:
@@ -260,7 +245,7 @@
     { typedef signed long long __type; };
 
 
-  // Select between arithmetic and enum: not possible to be both.
+  // Select between integral and enum: not possible to be both.
   template<typename _Tp, 
 	   bool _IsInt = is_integral<_Tp>::value,
 	   bool _IsSigned = is_signed<_Tp>::value,
@@ -284,20 +269,6 @@
     };
 
   template<typename _Tp>
-    struct __make_signed_selector<_Tp, false, true, false>
-    {
-      // GNU floating point types 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;
-      typedef typename __cond::type __cond_type;
-      typedef unsigned int __i_type;
-
-    public:
-      typedef typename conditional<__b1, __i_type, __cond_type>::type __type;
-    };
-
-  template<typename _Tp>
     struct __make_signed_selector<_Tp, false, false, true>
     {
     private:
Index: testsuite/20_util/make_signed/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(revision 124542)
+++ testsuite/20_util/make_signed/requirements/typedefs_neg.cc	(working copy)
@@ -39,15 +39,18 @@
 
   typedef void (fn_type) ();
   typedef make_signed<fn_type>::type  	test4_type;
+
+  typedef make_signed<float>::type  	test5_type;
 }
 
 // { dg-error "does not name a type" "" { target *-*-* } 34 }
 // { dg-error "instantiated from here" "" { target *-*-* } 36 }
 // { dg-error "instantiated from here" "" { target *-*-* } 38 }
 // { dg-error "instantiated from here" "" { target *-*-* } 41 }
+// { dg-error "instantiated from here" "" { target *-*-* } 43 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 320 }
-// { dg-error "declaration of" "" { target *-*-* } 268 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 291 }
+// { dg-error "declaration of" "" { target *-*-* } 253 }
 
 // { dg-excess-errors "At global scope" }
 // { dg-excess-errors "In instantiation of" }
Index: testsuite/20_util/make_signed/requirements/typedefs-1.cc
===================================================================
--- testsuite/20_util/make_signed/requirements/typedefs-1.cc	(revision 124542)
+++ testsuite/20_util/make_signed/requirements/typedefs-1.cc	(working copy)
@@ -50,13 +50,6 @@
   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, int>::value) );
 }
Index: testsuite/20_util/make_signed/requirements/typedefs-2.cc
===================================================================
--- testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 124542)
+++ testsuite/20_util/make_signed/requirements/typedefs-2.cc	(working copy)
@@ -50,13 +50,6 @@
   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) );
 }
Index: testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
===================================================================
--- testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(revision 124542)
+++ testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc	(working copy)
@@ -39,14 +39,17 @@
 
   typedef void (fn_type) ();
   typedef make_unsigned<fn_type>::type  	test4_type;
+
+  typedef make_unsigned<float>::type  		test5_type;
 }
 
 // { dg-error "does not name a type" "" { target *-*-* } 34 }
 // { dg-error "instantiated from here" "" { target *-*-* } 36 }
 // { dg-error "instantiated from here" "" { target *-*-* } 38 }
 // { dg-error "instantiated from here" "" { target *-*-* } 41 }
+// { dg-error "instantiated from here" "" { target *-*-* } 43 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 223 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 208 }
 // { dg-error "declaration of" "" { target *-*-* } 170 }
 
 // { dg-excess-errors "At global scope" }
Index: testsuite/20_util/make_unsigned/requirements/typedefs-1.cc
===================================================================
--- testsuite/20_util/make_unsigned/requirements/typedefs-1.cc	(revision 124542)
+++ testsuite/20_util/make_unsigned/requirements/typedefs-1.cc	(working copy)
@@ -50,13 +50,6 @@
   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 int>::value) );
 }
Index: testsuite/20_util/make_unsigned/requirements/typedefs-2.cc
===================================================================
--- testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 124542)
+++ testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(working copy)
@@ -50,13 +50,6 @@
   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) );
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]