aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2008-09-01 23:24:09 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2008-09-01 23:24:09 +0000
commita0230468417e750d1ae805ac38001aa88099d7fd (patch)
treed88bccb56445aaca3ce7c9b6d4bf65c1efba8031
parent26272ba2c429064f8b39f38771d879fc913114cc (diff)
downloadgcc-a0230468417e750d1ae805ac38001aa88099d7fd.zip
gcc-a0230468417e750d1ae805ac38001aa88099d7fd.tar.gz
gcc-a0230468417e750d1ae805ac38001aa88099d7fd.tar.bz2
type_traits (__make_unsigned_selector<>): Consider enums of size smaller than short.
* include/std/type_traits (__make_unsigned_selector<>): Consider enums of size smaller than short. (__make_signed_selector<>): Likewise. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust line numbers. * testsuite/20_util/make_usigned/requirements/typedefs_neg.cc: Adjust line numbers. * testsuite/20_util/make_signed/requirements/typedefs-2.cc: Ensure test_enum is the same size as short. * testsuite/20_util/make_unsigned/requirements/typedefs-2.cc: Ensure test_enum is the same size as short. From-SVN: r139875
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/include/std/type_traits30
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc3
-rw-r--r--libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc3
-rw-r--r--libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc2
6 files changed, 39 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 29adf70..0b2f5b9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2008-09-01 Mark Mitchell <mark@codesourcery.com>
+
+ * include/std/type_traits (__make_unsigned_selector<>): Consider
+ enums of size smaller than short.
+ (__make_signed_selector<>): Likewise.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
+ Adjust line numbers.
+ * testsuite/20_util/make_usigned/requirements/typedefs_neg.cc:
+ Adjust line numbers.
+ * testsuite/20_util/make_signed/requirements/typedefs-2.cc:
+ Ensure test_enum is the same size as short.
+ * testsuite/20_util/make_unsigned/requirements/typedefs-2.cc:
+ Ensure test_enum is the same size as short.
+
2008-08-31 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
* acinclude.m4 <enable_symvers>: Don't use symvers on Windows.
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 1a75918..87fdff1 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -455,15 +455,18 @@ namespace std
struct __make_unsigned_selector<_Tp, false, true>
{
private:
- // GNU enums start with sizeof short.
- typedef unsigned short __smallest;
- static const bool __b1 = sizeof(_Tp) <= sizeof(__smallest);
+ // With -fshort-enums, an enum may be as small as a char.
+ typedef unsigned char __smallest;
+ static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
+ static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
- typedef conditional<__b2, unsigned int, unsigned long> __cond;
- typedef typename __cond::type __cond_type;
+ typedef conditional<__b2, unsigned int, unsigned long> __cond2;
+ typedef typename __cond2::type __cond2_type;
+ typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
+ typedef typename __cond1::type __cond1_type;
public:
- typedef typename conditional<__b1, __smallest, __cond_type>::type __type;
+ typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
};
// Given an integral/enum type, return the corresponding unsigned
@@ -530,15 +533,18 @@ namespace std
struct __make_signed_selector<_Tp, false, true>
{
private:
- // GNU enums start with sizeof short.
- typedef signed short __smallest;
- static const bool __b1 = sizeof(_Tp) <= sizeof(__smallest);
+ // With -fshort-enums, an enum may be as small as a char.
+ typedef signed char __smallest;
+ static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
+ static const bool __b1 = sizeof(_Tp) <= sizeof(signed short);
static const bool __b2 = sizeof(_Tp) <= sizeof(signed int);
- typedef conditional<__b2, signed int, signed long> __cond;
- typedef typename __cond::type __cond_type;
+ typedef conditional<__b2, signed int, signed long> __cond2;
+ typedef typename __cond2::type __cond2_type;
+ typedef conditional<__b1, signed short, __cond2_type> __cond1;
+ typedef typename __cond1::type __cond1_type;
public:
- typedef typename conditional<__b1, __smallest, __cond_type>::type __type;
+ typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
};
// Given an integral/enum type, return the corresponding signed
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
index ea4de37..b0f93b0 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
@@ -24,7 +24,8 @@
#include <type_traits>
#include <testsuite_hooks.h>
-enum test_enum { first_selection };
+// Ensure that this enum has "short" as its underlying type.
+enum test_enum { first_selection = ((unsigned char)-1) + 1 };
void test01()
{
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 dc33931..59f6798 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
@@ -49,8 +49,8 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 41 }
// { dg-error "instantiated from here" "" { target *-*-* } 43 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 549 }
-// { dg-error "declaration of" "" { target *-*-* } 515 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 555 }
+// { dg-error "declaration of" "" { target *-*-* } 518 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }
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 ce318c8..4f64120 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
@@ -24,7 +24,8 @@
#include <type_traits>
#include <testsuite_hooks.h>
-enum test_enum { first_selection };
+// Ensure that this enum has "short" as its underlying type.
+enum test_enum { first_selection = ((unsigned char)-1) + 1 };
void test01()
{
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 0b02e33..170183d 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
@@ -49,7 +49,7 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 41 }
// { dg-error "instantiated from here" "" { target *-*-* } 43 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 474 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 477 }
// { dg-error "declaration of" "" { target *-*-* } 440 }
// { dg-excess-errors "At global scope" }