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]

(C++) patch to TEMPLATE_PARM_INDEX


Saying 1+3*sizeof(HOST_WIDE_INT)/sizeof(char*) doesn't work; if 
s(H)/s(c*) > 1, alignment will probably make the one tree larger than it
would normally be, throwing off our calculations.  So just work backwards
from something we know to be correct...

1999-12-15  Jason Merrill  <jason@yorick.cygnus.com>

	* cp-tree.def (TEMPLATE_PARM_INDEX): Calculate size using
	sizeof (struct tree_common).

Index: cp-tree.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.def,v
retrieving revision 1.43
diff -c -p -r1.43 cp-tree.def
*** cp-tree.def	1999/12/05 00:49:26	1.43
--- cp-tree.def	1999/12/15 09:14:46
***************
*** 1,7 ****
  /* This file contains the definitions and documentation for the
     additional tree codes used in the GNU C++ compiler (see tree.def
     for the standard codes).
!    Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998, 1999 Free Software Foundation, Inc.
     Hacked by Michael Tiemann (tiemann@cygnus.com)
  
  This file is part of GNU CC.
--- 1,7 ----
  /* This file contains the definitions and documentation for the
     additional tree codes used in the GNU C++ compiler (see tree.def
     for the standard codes).
!    Copyright (C) 1987,88,90,93,97-8,1999 Free Software Foundation, Inc.
     Hacked by Michael Tiemann (tiemann@cygnus.com)
  
  This file is part of GNU CC.
*************** DEFTREECODE (TEMPLATE_DECL, "template_de
*** 125,136 ****
     the types of things; the ORIG_LEVEL is the level when we are
     worrying about instantiating things.  */
  DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", 'x', 
! 	     /* The addition of (sizeof(char*) - 1) in the next
! 		expression is to ensure against the case where
! 		sizeof(char*) does not evenly divide
! 		sizeof(HOST_WIDE_INT).  */
! 	     1 + ((3 * sizeof (HOST_WIDE_INT) + sizeof(char*) - 1)
! 		  / sizeof (char*)))
  
  /* Index into a template parameter list.  This parameter must be a type.
     The TYPE_FIELDS value will be a TEMPLATE_PARM_INDEX.  */
--- 125,139 ----
     the types of things; the ORIG_LEVEL is the level when we are
     worrying about instantiating things.  */
  DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", 'x', 
! 	     /* The addition of (sizeof(tree) - 1) in the next expression
! 		is to handle the case when padding pushes us past an even
! 		multiple of sizeof(tree).  */
! 	     /* We used to try to calculate this using
! 		1+3*sizeof(HOST_WIDE_INT), but that fails if alignment
! 		makes it bigger.  */
! 	     ((sizeof (template_parm_index) - sizeof (struct tree_common))
! 	      + sizeof (tree) - 1)
! 	     / sizeof (tree))
  
  /* Index into a template parameter list.  This parameter must be a type.
     The TYPE_FIELDS value will be a TEMPLATE_PARM_INDEX.  */


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