Minor bugs in new code in expr.c

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Mon Apr 10 04:46:00 GMT 2000


These came up in the process of getting GNAT to work with the current
sources.

Mon Apr 10 07:21:13 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* expr.c (get_inner_reference): Correct some WITH_RECORD_EXPR cases.
	(expand_expr, case CONVERT_EXPR): Pass proper alignment to store_field.

*** expr.c	2000/04/01 00:09:21	1.228
--- expr.c	2000/04/10 11:40:58
*************** get_inner_reference (exp, pbitsize, pbit
*** 5023,5027 ****
  	    this_offset = build (WITH_RECORD_EXPR, sizetype, this_offset, exp);
  
! 	  offset = size_binop (PLUS_EXPR, offset, DECL_FIELD_OFFSET (field));
  	  bit_offset = size_binop (PLUS_EXPR, bit_offset,
  				   DECL_FIELD_BIT_OFFSET (field));
--- 5023,5027 ----
  	    this_offset = build (WITH_RECORD_EXPR, sizetype, this_offset, exp);
  
! 	  offset = size_binop (PLUS_EXPR, offset, this_offset);
  	  bit_offset = size_binop (PLUS_EXPR, bit_offset,
  				   DECL_FIELD_BIT_OFFSET (field));
*************** get_inner_reference (exp, pbitsize, pbit
*** 5030,5033 ****
--- 5030,5034 ----
  	    alignment = MIN (alignment, DECL_OFFSET_ALIGN (field));
  	}
+ 
        else if (TREE_CODE (exp) == ARRAY_REF)
  	{
*************** get_inner_reference (exp, pbitsize, pbit
*** 5035,5038 ****
--- 5036,5040 ----
  	  tree domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
  	  tree low_bound = (domain ? TYPE_MIN_VALUE (domain) : 0);
+ 	  tree unit_size = TYPE_SIZE_UNIT (TREE_TYPE (exp));
  
  	  /* We assume all arrays have sizes that are a multiple of a byte.
*************** get_inner_reference (exp, pbitsize, pbit
*** 5044,5056 ****
  				 index, low_bound));
  
  	  if (! TREE_CONSTANT (index)
  	      && contains_placeholder_p (index))
  	    index = build (WITH_RECORD_EXPR, TREE_TYPE (index), index, exp);
  
  	  offset = size_binop (PLUS_EXPR, offset,
  			       size_binop (MULT_EXPR,
  					   convert (sizetype, index),
! 					   TYPE_SIZE_UNIT (TREE_TYPE (exp))));
  	}
        else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  	       && ! ((TREE_CODE (exp) == NOP_EXPR
--- 5046,5066 ----
  				 index, low_bound));
  
+ 	  /* If the index has a self-referential type, pass it to a
+ 	     WITH_RECORD_EXPR; if the component size is, pass our
+ 	     component to one.  */
  	  if (! TREE_CONSTANT (index)
  	      && contains_placeholder_p (index))
  	    index = build (WITH_RECORD_EXPR, TREE_TYPE (index), index, exp);
+ 	  if (! TREE_CONSTANT (unit_size)
+ 	      && contains_placeholder_p (unit_size))
+ 	    unit_size = build (WITH_RECORD_EXPR, sizetype, unit_size,
+ 			       TREE_OPERAND (exp, 0));
  
  	  offset = size_binop (PLUS_EXPR, offset,
  			       size_binop (MULT_EXPR,
  					   convert (sizetype, index),
! 					   unit_size));
  	}
+ 
        else if (TREE_CODE (exp) != NON_LVALUE_EXPR
  	       && ! ((TREE_CODE (exp) == NOP_EXPR
*************** expand_expr (exp, target, tmode, modifie
*** 7061,7065 ****
  			      GET_MODE_BITSIZE (mode)),
  			 0, TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
! 			 VOIDmode, 0, 1, int_size_in_bytes (type), 0);
  	  else
  	    abort ();
--- 7071,7076 ----
  			      GET_MODE_BITSIZE (mode)),
  			 0, TYPE_MODE (valtype), TREE_OPERAND (exp, 0),
! 			 VOIDmode, 0, BITS_PER_UNIT,
! 			 int_size_in_bytes (type), 0);
  	  else
  	    abort ();


More information about the Gcc-patches mailing list