FreeBSD/contrib/gcc/cp/class.c
/* Returns TRUE iff we need a cookie when dynamically allocating an
   array whose elements have the indicated class TYPE.  */
Returns TRUE iff we need a cookie when dynamically allocating an
array whose elements have the indicated class TYPE.
Returns TRUE iff we need a cookie when dynamically allocating an array whose elements have the indicated class TYPE .
static bool
type_requires_array_cookie (tree type)
{
  tree fns;
  bool has_two_argument_delete_p = false;
  gcc_assert (CLASS_TYPE_P (type));
  if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
    return true;
  fns = lookup_fnfields (TYPE_BINFO (type),
			 ansi_opname (VEC_DELETE_EXPR),
			 0);
  if (!fns || fns == error_mark_node)
    return false;
  for (fns = BASELINK_FUNCTIONS (fns); fns; fns = OVL_NEXT (fns))
    {
      tree fn;
      tree second_parm;
      fn = OVL_CURRENT (fns);
      second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn)));
      if (second_parm == void_list_node)
	return false;
      if (TREE_CHAIN (second_parm) == void_list_node
	  && same_type_p (TREE_VALUE (second_parm), sizetype))
	has_two_argument_delete_p = true;
    }
  return has_two_argument_delete_p;
}
static bool type_requires_array_cookie ( tree type ) { tree fns ; bool has_two_argument_delete_p = false ; gcc_assert ( CLASS_TYPE_P ( type ) ) ; if ( TYPE_HAS_NONTRIVIAL_DESTRUCTOR ( type ) ) return true ; fns = lookup_fnfields ( TYPE_BINFO ( type ) , ansi_opname ( VEC_DELETE_EXPR ) , 0 ) ; if ( ! fns || fns == error_mark_node ) return false ; for ( fns = BASELINK_FUNCTIONS ( fns ) ; fns ; fns = OVL_NEXT ( fns ) ) { tree fn ; tree second_parm ; fn = OVL_CURRENT ( fns ) ; second_parm = TREE_CHAIN ( TYPE_ARG_TYPES ( TREE_TYPE ( fn ) ) ) ; if ( second_parm == void_list_node ) return false ; if ( TREE_CHAIN ( second_parm ) == void_list_node && same_type_p ( TREE_VALUE ( second_parm ) , sizetype ) ) has_two_argument_delete_p = true ; } return has_two_argument_delete_p ; }
Returns TRUE iff we need a cookie when dynamically allocating an
array whose elements have the indicated class TYPE.
Returns TRUE iff we need a cookie when dynamically allocating an array whose elements have the indicated class TYPE .
/* If there's a non-trivial destructor, we need a cookie.  In order
     to iterate through the array calling the destructor for each
     element, we'll have to know how many elements there are.  */ /* If the usual deallocation function is a two-argument whose second
     argument is of type `size_t', then we have to pass the size of
     the array to the deallocation function, so we will need to store
     a cookie.  */ /*protect=*/ /* If there are no `operator []' members, or the lookup is
     ambiguous, then we don't need a cookie.  */ /* Loop through all of the functions.  */ /* Select the current function.  */ /* See if this function is a one-argument delete function.  If
	 it is, then it will be the usual deallocation function.  */ /* Otherwise, if we have a two-argument function and the second
	 argument is `size_t', it will be the usual deallocation
	 function -- unless there is one-argument function, too.  */