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]

[Ada PATCH] Clean-up Ada front-end use of TREE_OVERFLOW


The following patch tweaks the gnat front-end to only call TREE_OVERFLOW
on constant nodes.  Both the middle-end and Ada front-end only ever set
or reset the TREE_OVERFLOW flag on INTEGER_CST, REAL_CST, COMPLEX_CST
and VECTOR_CST tree nodes.  As part of the ongoing rationalization of
TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW, this corrects the one place
in the Ada front-end that currently trips up the planned "tree.h"
assertion checking for misuse of the TREE_OVERFLOW flag.  In the max_size
function, the only relevant constant type is INTEGER_CST, so the tweaks
below limit the TREE_OVERFLOW usage to only those cases where it may
potentially be set.


Diagnosing these these types of problem in GCC's Ada front-end would be
easier if the following patch could be approved (ping?):
http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00175.html


The following patch has been tested on i686-pc-linux-gnu, with a bootstrap
including Ada, and regression tested with a top-level "make -k check" with
no new failures.  This patch resolves the 8 ACATS regressions that would
otherwise be introduced once TREE_OVERFLOW checking is enabled.

Ok for mainline?



2005-05-15  Roger Sayle  <roger@eyesopen.com>

	* utils.c (max_size): Only test for TREE_OVERFLOW on INTEGER_CST
	nodes.


Index: utils.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/utils.c,v
retrieving revision 1.95
diff -c -3 -p -r1.95 utils.c
*** utils.c	1 Apr 2005 05:28:01 -0000	1.95
--- utils.c	15 May 2005 14:04:14 -0000
*************** max_size (tree exp, bool max_p)
*** 1989,2000 ****
  	       Likewise, handle a MINUS_EXPR or PLUS_EXPR with the LHS
  	       overflowing or the maximum possible value and the RHS
  	       a variable.  */
! 	    if (max_p && code == MIN_EXPR && TREE_OVERFLOW (rhs))
  	      return lhs;
! 	    else if (max_p && code == MIN_EXPR && TREE_OVERFLOW (lhs))
  	      return rhs;
  	    else if ((code == MINUS_EXPR || code == PLUS_EXPR)
! 		     && ((TREE_CONSTANT (lhs) && TREE_OVERFLOW (lhs))
  			 || operand_equal_p (lhs, TYPE_MAX_VALUE (type), 0))
  		     && !TREE_CONSTANT (rhs))
  	      return lhs;
--- 1989,2007 ----
  	       Likewise, handle a MINUS_EXPR or PLUS_EXPR with the LHS
  	       overflowing or the maximum possible value and the RHS
  	       a variable.  */
! 	    if (max_p
! 		&& code == MIN_EXPR
! 		&& TREE_CODE (rhs) == INTEGER_CST
! 		&& TREE_OVERFLOW (rhs))
  	      return lhs;
! 	    else if (max_p
! 		     && code == MIN_EXPR
! 		     && TREE_CODE (lhs) == INTEGER_CST
! 		     && TREE_OVERFLOW (lhs))
  	      return rhs;
  	    else if ((code == MINUS_EXPR || code == PLUS_EXPR)
! 		     && ((TREE_CODE (lhs) == INTEGER_CST
! 			  && TREE_OVERFLOW (lhs))
  			 || operand_equal_p (lhs, TYPE_MAX_VALUE (type), 0))
  		     && !TREE_CONSTANT (rhs))
  	      return lhs;

Roger
--


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