aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorRafael Avila de Espindola <espindola@google.com>2007-05-16 16:26:21 +0000
committerRafael Espindola <espindola@gcc.gnu.org>2007-05-16 16:26:21 +0000
commitc74a03d23e9b1159e871f41552c1d2f73eb9812c (patch)
tree9256899583d49f3bd7680b74084471ceefc734be /gcc/c-common.c
parent0d8c60585e19e9d3eb1373528be19c33629d0c41 (diff)
downloadgcc-c74a03d23e9b1159e871f41552c1d2f73eb9812c.zip
gcc-c74a03d23e9b1159e871f41552c1d2f73eb9812c.tar.gz
gcc-c74a03d23e9b1159e871f41552c1d2f73eb9812c.tar.bz2
c-common.c (c_common_signed_or_unsigned_type): Emulate c_common_unsigned_type behavior.
2007-05-16 Rafael Avila de Espindola <espindola@google.com> * c-common.c (c_common_signed_or_unsigned_type): Emulate c_common_unsigned_type behavior. From-SVN: r124771
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index d132be9..6aa5e64 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2065,10 +2065,43 @@ c_common_signed_type (tree type)
tree
c_common_signed_or_unsigned_type (int unsignedp, tree type)
{
+ tree type1;
if (!INTEGRAL_TYPE_P (type)
|| TYPE_UNSIGNED (type) == unsignedp)
return type;
+ /* This block of code emulates the behavior of the old
+ c_common_unsigned_type. In particular, it returns
+ long_unsigned_type_node if passed a long, even when a int would
+ have the same size. This is necessary for warnings to work
+ correctly in archs where sizeof(int) == sizeof(long) */
+
+ type1 = TYPE_MAIN_VARIANT (type);
+ if (type1 == signed_char_type_node || type1 == char_type_node || type1 == unsigned_char_type_node)
+ return unsignedp ? unsigned_char_type_node : signed_char_type_node;
+ if (type1 == integer_type_node || type1 == unsigned_type_node)
+ return unsignedp ? unsigned_type_node : integer_type_node;
+ if (type1 == short_integer_type_node || type1 == short_unsigned_type_node)
+ return unsignedp ? short_unsigned_type_node : short_integer_type_node;
+ if (type1 == long_integer_type_node || type1 == long_unsigned_type_node)
+ return unsignedp ? long_unsigned_type_node : long_integer_type_node;
+ if (type1 == long_long_integer_type_node || type1 == long_long_unsigned_type_node)
+ return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
+ if (type1 == widest_integer_literal_type_node || type1 == widest_unsigned_literal_type_node)
+ return unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node;
+#if HOST_BITS_PER_WIDE_INT >= 64
+ if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
+ return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
+#endif
+ if (type1 == intDI_type_node || type1 == unsigned_intDI_type_node)
+ return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
+ if (type1 == intSI_type_node || type1 == unsigned_intSI_type_node)
+ return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
+ if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node)
+ return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
+ if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
+ return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
+
/* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
the precision; they have precision set to match their range, but
may use a wider mode to match an ABI. If we change modes, we may