This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
c_common_type_for_mode: return integer type even for pointer mode
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 21 Jul 2003 23:24:32 -0300
- Subject: c_common_type_for_mode: return integer type even for pointer mode
- Organization: GCC Team, Red Hat
If pointer mode happens to not match any of the standard integer
types, c_common_type_for_mode ends up returning a pointer_type, not an
integer type of the required signedness. This breaks code such as
unwind-*, that typedef _Unwind_Ptr to an unsigned integer type of
pointer mode: we end up rejecting e.g. bitwise operations that do not
apply to pointers. This patch fixes it. Bootstrapped on
i686-pc-linux-gnu (not much use, I realize :-) and tested with a port
that uses partial int mode for pointers. Approved by Richard
Henderson. I'm checking it in.
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* c-common.c (c_common_type_for_mode): Return integer types for
pointer modes.
Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.433
diff -u -p -r1.433 c-common.c
--- gcc/c-common.c 19 Jul 2003 14:46:59 -0000 1.433
+++ gcc/c-common.c 22 Jul 2003 02:20:57 -0000
@@ -1859,10 +1859,10 @@ c_common_type_for_mode (enum machine_mod
return long_double_type_node;
if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
- return build_pointer_type (char_type_node);
+ return unsignedp ? make_unsigned_type (mode) : make_signed_type (mode);
if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
- return build_pointer_type (integer_type_node);
+ return unsignedp ? make_unsigned_type (mode) : make_signed_type (mode);
switch (mode)
{
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer