This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: Excise CHAR_TYPE from Java


Nathan Sidwell writes:
 > I noticed that tree.def said this
 > 	/* CHAR in Pascal; not used in C.
 > 	   No special fields needed.  */
 > about CHAR_TYPE.  Well, it is used in Java too, but only just.  Rather
 > than fix the comment to reflect reality, I decided to fix reality (much more
 > satisfying :)
 > 
 > This patch removes the Java FE's use of CHAR_TYPE, by adding explicit
 > checks for char_type_node as appropriate -- that is what the C++ FE does
 > when it needs to distinguish identically laid out wchar_t from short or int
 > (or whatever it's identical to).
 > 
 > Obviously, if this goes in, the next step will be to nuke the uses of
 > CHAR_TYPE from the middle end.
 > 
 > booted & tested on i686-pc-linux-gnu, ok?
 > 
 > Let me know if you don't think this is an appropriate cleanup for now.

So, gcc no longer has a character type -- it's just a special case of
integer.  That seems reasonable to me, but it doesn't fix anything
that's broken.

I have no opinion one way or another whether this change really needs
to go in now.  I have no particular objection to it.

        switch (TYPE_PRECISION (type))
  	{
! 	case  8:
! 	  {
! 	    int special_val = 5 + (type == char_type_node);
! 	    return max < special_val ? 0 : special_val;
! 	  }
! 	case 16:
! 	  {
! 	    int special_val = 7 - (type == char_type_node);
! 	    return max < special_val ? 0 : special_val;
! 	  }

This seems excessively cute.  :-)

What's wrong with

*************** adjust_typed_op (tree type, int max)
*** 882,888 ****
      case BOOLEAN_TYPE:
        return TYPE_PRECISION (type) == 32 || max < 5 ? 0 : 5;
-     case CHAR_TYPE:
-       return TYPE_PRECISION (type) == 32 || max < 6 ? 0 : 6;
      case INTEGER_TYPE:
        switch (TYPE_PRECISION (type))
  	{
--- 882,888 ----
      case BOOLEAN_TYPE:
        return TYPE_PRECISION (type) == 32 || max < 5 ? 0 : 5;
      case INTEGER_TYPE:
+       if (type == char_type_node)
+ 	return TYPE_PRECISION (type) == 32 || max < 6 ? 0 : 6;
        switch (TYPE_PRECISION (type))
  	{



Andrew.


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