FreeBSD/contrib/gcc/cp/class.c
/* Set BINFO_OFFSET for all of the virtual bases for RLI->T.  Update
   TYPE_ALIGN and TYPE_SIZE for T.  OFFSETS gives the location of
   empty subobjects of T.  */
Set BINFO_OFFSET for all of the virtual bases for RLI->T.
Set BINFO_OFFSET for all of the virtual bases for RLI - > T .
static void
layout_virtual_bases (record_layout_info rli, splay_tree offsets)
{
  tree vbase;
  tree t = rli->t;
  bool first_vbase = true;
  tree *next_field;
  if (BINFO_N_BASE_BINFOS (TYPE_BINFO (t)) == 0)
    return;
  if (!abi_version_at_least(2))
    {
      finish_record_layout (rli, false);
#ifdef STRUCTURE_SIZE_BOUNDARY
      if (! TYPE_PACKED (t))
	TYPE_ALIGN (t) = MAX (TYPE_ALIGN (t), (unsigned) STRUCTURE_SIZE_BOUNDARY);
#endif
      rli->offset = TYPE_SIZE_UNIT (t);
      rli->bitpos = bitsize_zero_node;
      rli->record_align = TYPE_ALIGN (t);
    }
  next_field = &TYPE_FIELDS (t);
  while (*next_field)
    next_field = &TREE_CHAIN (*next_field);
  for (vbase = TYPE_BINFO (t); vbase; vbase = TREE_CHAIN (vbase))
    {
      if (!BINFO_VIRTUAL_P (vbase))
	continue;
      if (!BINFO_PRIMARY_P (vbase))
	{
	  tree basetype = TREE_TYPE (vbase);
	  next_field = build_base_field (rli, vbase,
					 offsets, next_field);
	  if (warn_abi
	      && first_vbase
	      && (tree_int_cst_lt
		  (size_binop (CEIL_DIV_EXPR,
			       round_up (CLASSTYPE_SIZE (t),
					 CLASSTYPE_ALIGN (basetype)),
			       bitsize_unit_node),
		   BINFO_OFFSET (vbase))))
	    warning (OPT_Wabi,
		     "offset of virtual base %qT is not ABI-compliant and "
		     "may change in a future version of GCC",
		     basetype);
	  first_vbase = false;
	}
    }
}
static void layout_virtual_bases ( record_layout_info rli , splay_tree offsets ) { tree vbase ; tree t = rli -> t ; bool first_vbase = true ; tree * next_field ; if ( BINFO_N_BASE_BINFOS ( TYPE_BINFO ( t ) ) == 0 ) return ; if ( ! abi_version_at_least ( 2 ) ) { finish_record_layout ( rli , false ) ; #ifdef STRUCTURE_SIZE_BOUNDARY if ( ! TYPE_PACKED ( t ) ) TYPE_ALIGN ( t ) = MAX ( TYPE_ALIGN ( t ) , ( unsigned ) STRUCTURE_SIZE_BOUNDARY ) ; #endif rli -> offset = TYPE_SIZE_UNIT ( t ) ; rli -> bitpos = bitsize_zero_node ; rli -> record_align = TYPE_ALIGN ( t ) ; } next_field = & TYPE_FIELDS ( t ) ; while ( * next_field ) next_field = & TREE_CHAIN ( * next_field ) ; for ( vbase = TYPE_BINFO ( t ) ; vbase ; vbase = TREE_CHAIN ( vbase ) ) { if ( ! BINFO_VIRTUAL_P ( vbase ) ) continue ; if ( ! BINFO_PRIMARY_P ( vbase ) ) { tree basetype = TREE_TYPE ( vbase ) ; next_field = build_base_field ( rli , vbase , offsets , next_field ) ; if ( warn_abi && first_vbase && ( tree_int_cst_lt ( size_binop ( CEIL_DIV_EXPR , round_up ( CLASSTYPE_SIZE ( t ) , CLASSTYPE_ALIGN ( basetype ) ) , bitsize_unit_node ) , BINFO_OFFSET ( vbase ) ) ) ) warning ( OPT_Wabi , " " " " , basetype ) ; first_vbase = false ; } } }
Set BINFO_OFFSET for all of the virtual bases for RLI->T.
Set BINFO_OFFSET for all of the virtual bases for RLI - > T .
/* In G++ 3.2, we incorrectly rounded the size before laying out
	 the virtual bases.  */ /*free_p=*/ /* Packed structures don't need to have minimum size.  */ /* Find the last field.  The artificial fields created for virtual
     bases will go after the last extant field to date.  */ /* Go through the virtual bases, allocating space for each virtual
     base that is not already a primary base class.  These are
     allocated in inheritance graph order.  */ /* This virtual base is not a primary base of any class in the
	     hierarchy, so we have to add space for it.  */ /* If the first virtual base might have been placed at a
	     lower address, had we started from CLASSTYPE_SIZE, rather
	     than TYPE_SIZE, issue a warning.  There can be both false
	     positives and false negatives from this warning in rare
	     cases; to deal with all the possibilities would probably
	     require performing both layout algorithms and comparing
	     the results which is not particularly tractable.  */