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]

PATCH to get_unwidened


While working on PR 13371, I noticed that the C++ front end no longer
narrows a COMPONENT_REF to an enum bitfield because TYPE_PRECISION is
now set to the number of bits necessary to represent all of the
enumerators, whereas previously it matched TYPE_SIZE.

get_unwidened was using TYPE_PRECISION to decide whether or not a narrowing
would be useful, which should be based on TYPE_SIZE.  The test previously
checked whether or not the specified number of bits in the bitfield was
less than the number of bits used to represent the type; this patch changes
it to check whether or not the narrowed type is actually smaller than the
normal type.

Tested x86_64-pc-linux-gnu, applied to trunk.  This affects the testcase
for 13371, but I haven't found a testcase that will fail because we don't
do the narrowing.

2003-12-19  Jason Merrill  <jason@redhat.com>

	* tree.c (get_unwidened): Decide whether to narrow a bitfield
	reference based on TYPE_SIZE, not TYPE_PRECISION.

*** tree.c.~1~	2003-12-19 17:33:34.000000000 -0500
--- tree.c	2003-12-19 00:16:30.000000000 -0500
*************** get_unwidened (tree op, tree for_type)
*** 4123,4129 ****
  	 The resulting extension to its nominal type (a fullword type)
  	 must fit the same conditions as for other extensions.  */
  
!       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
  	  && (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
  	  && (! uns || final_prec <= innerprec || unsignedp)
  	  && type != 0)
--- 4123,4129 ----
  	 The resulting extension to its nominal type (a fullword type)
  	 must fit the same conditions as for other extensions.  */
  
!       if (INT_CST_LT_UNSIGNED (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (op)))
  	  && (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
  	  && (! uns || final_prec <= innerprec || unsignedp)
  	  && type != 0)

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