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]

Add handling for "superflat" Ada arrays


This is needed for the case of dynamically-sized arrays whose upper
bound is more than one lower than the lower bound.  This is needed for
lots of cases in Ada.

Tested on i686-pc-linux-gnu.

2003-04-14  Richard Kenner  <kenner at vlsi1 dot ultra dot nyu dot edu>

	* stor-layout.c (layout_type, case ARRAY_TYPE): Add missing code to
	handle "superflat arrays" in Ada.

*** gcc/stor-layout.c	11 Apr 2003 16:22:25 -0000	1.149
--- gcc/stor-layout.c	11 Apr 2003 20:19:44 -0000
*************** layout_type (type)
*** 1741,1744 ****
--- 1741,1753 ----
  	      }
  
+ 	    /* If neither bound is a constant and sizetype is signed, make
+ 	       sure the size is never negative.  We should really do this
+ 	       if *either* bound is non-constant, but this is the best
+ 	       compromise between C and Ada.  */
+ 	    if (! TREE_UNSIGNED (sizetype)
+ 		&& TREE_CODE (TYPE_MIN_VALUE (index)) != INTEGER_CST
+ 		&& TREE_CODE (TYPE_MAX_VALUE (index)) != INTEGER_CST)
+ 	      length = size_binop (MAX_EXPR, length, size_zero_node);
+ 
  	    TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
  					   convert (bitsizetype, length));


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