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]

[3.3] Patch for PR c/15549


Hello,

following patch fixes PR c/15549.

Bootstrapping 3.3 branch in progress.

Josef


2004-06-01  Josef Zlomek  <zlomekj@suse.cz>

	Backport from mainline:
	2003-08-19  Mark Mitchell  <mark@codesourcery.com>
      
	        PR c++/11946
        	* convert.c (convert_to_integer): Use CONVERT_EXPR (instead of             
	        NOP_EXPR) when necessary.

Index: convert.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/gcc/convert.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -c -p -c -3 -p -r1.32 -r1.33
*** convert.c	28 Jul 2003 15:42:16 -0000	1.32
--- convert.c	20 Aug 2003 07:06:39 -0000	1.33
*************** convert_to_integer (tree type, tree expr
*** 349,355 ****
  	 we are truncating EXPR.  */
  
        else if (outprec >= inprec)
! 	return build1 (NOP_EXPR, type, expr);
  
        /* If TYPE is an enumeral type or a type with a precision less
  	 than the number of bits in its mode, do the conversion to the
--- 349,375 ----
  	 we are truncating EXPR.  */
  
        else if (outprec >= inprec)
! 	{
! 	  enum tree_code code;
! 
! 	  /* If the precision of the EXPR's type is K bits and the
! 	     destination mode has more bits, and the sign is changing,
! 	     it is not safe to use a NOP_EXPR.  For example, suppose
! 	     that EXPR's type is a 3-bit unsigned integer type, the
! 	     TYPE is a 3-bit signed integer type, and the machine mode
! 	     for the types is 8-bit QImode.  In that case, the
! 	     conversion necessitates an explicit sign-extension.  In
! 	     the signed-to-unsigned case the high-order bits have to
! 	     be cleared.  */
! 	  if (TREE_UNSIGNED (type) != TREE_UNSIGNED (TREE_TYPE (expr))
! 	      && (TYPE_PRECISION (TREE_TYPE (expr))
! 		  != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr)))))
! 	    code = CONVERT_EXPR;
! 	  else
! 	    code = NOP_EXPR;
! 
! 	  return build1 (code, type, expr);
! 	}
  
        /* If TYPE is an enumeral type or a type with a precision less
  	 than the number of bits in its mode, do the conversion to the


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