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: [PATCH] PR19100: truthvalue_conversion vs. TREE_CONSTANT_OVERFLOW


On Tue, 21 Dec 2004, Mark Mitchell wrote:
> Thanks; I will revise my query.  Roger, it seems to me that perhaps we
> should leave c_common_truthvalue_conversion alone, and instead not mark
> the conversion of 0x100 to signed char with TREE_CONSTANT_OVERFLOW.  As
> Joseph says, this is just implementation-defined, and we may as well
> define it as just another way of writing zero.

I still think that although this an improvement, its still papering over
the deeper c_common_truthvalue_conversion issue.  The following patch
tweaks fold_convert_const to prevent integeral type conversions of
constants from setting the TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW
fields.  Tested on i686-pc-linux-gnu with a full "make bootstrap", all
default languages, and regression tested with a top-level "make -k
check".

Unfortunately, there are two new failures both in gcc.dg/bitfld-2.c,
missing warnings on lines 15 and 21.  Joseph are these diagnostics for
overflow on bitfield assignment required by the language standards,
and if so is there an easy alternate way of generating them?  The good
news, however, is that is does resolve PR middle-end/19100.

Thoughts?


2004-12-21  Roger Sayle  <roger@eyesopen.com>

	PR middle-end/19100

	* fold-const.c (fold_convert_const): Don't set TREE_OVERFLOW when
	converting constants from one integer type to another.

	* gcc.dg/conv-3.c: New test case.


Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.486
diff -c -3 -p -r1.486 fold-const.c
*** fold-const.c	18 Dec 2004 19:03:49 -0000	1.486
--- fold-const.c	21 Dec 2004 21:38:10 -0000
*************** fold_convert_const (enum tree_code code,
*** 1730,1743 ****
  	  t = build_int_cst_wide (type, TREE_INT_CST_LOW (arg1),
  				  TREE_INT_CST_HIGH (arg1));

! 	  t = force_fit_type (t,
! 			      /* Don't set the overflow when
! 			      	 converting a pointer  */
! 			      !POINTER_TYPE_P (TREE_TYPE (arg1)),
! 			      (TREE_INT_CST_HIGH (arg1) < 0
! 			       && (TYPE_UNSIGNED (type)
! 				   < TYPE_UNSIGNED (TREE_TYPE (arg1))))
! 			      | TREE_OVERFLOW (arg1),
  			      TREE_CONSTANT_OVERFLOW (arg1));
  	  return t;
  	}
--- 1730,1737 ----
  	  t = build_int_cst_wide (type, TREE_INT_CST_LOW (arg1),
  				  TREE_INT_CST_HIGH (arg1));

! 	  /* We don't care about overflow in conversions.  */
! 	  t = force_fit_type (t, 0, TREE_OVERFLOW (arg1),
  			      TREE_CONSTANT_OVERFLOW (arg1));
  	  return t;
  	}


Roger
--


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