FreeBSD/contrib/gcc/cp/class.c
/* Layout the base given by BINFO in the class indicated by RLI.
   *BASE_ALIGN is a running maximum of the alignments of
   any base class.  OFFSETS gives the location of empty base
   subobjects.  T is the most derived type.  Return nonzero if the new
   object cannot be nearly-empty.  A new FIELD_DECL is inserted at
   *NEXT_FIELD, unless BINFO is for an empty base class.

   Returns the location at which the next field should be inserted.  */
Layout the base given by BINFO in the class indicated by RLI.
BASE_ALIGN is a running maximum of the alignments of
any base class.  OFFSETS gives the location of empty base
subobjects.  T is the most derived type.  Return nonzero if the new
object cannot be nearly-empty.  A new FIELD_DECL is inserted at
NEXT_FIELD, unless BINFO is for an empty base class.

Returns the location at which the next field should be inserted.
Layout the base given by BINFO in the class indicated by RLI . BASE_ALIGN is a running maximum of the alignments of any base class . OFFSETS gives the location of empty base subobjects . T is the most derived type . Return nonzero if the new object cannot be nearly - empty . A new FIELD_DECL is inserted at NEXT_FIELD unless BINFO is for an empty base class . Returns the location at which the next field should be inserted .
static tree *
build_base_field (record_layout_info rli, tree binfo,
		  splay_tree offsets, tree *next_field)
{
  tree t = rli->t;
  tree basetype = BINFO_TYPE (binfo);
  if (!COMPLETE_TYPE_P (basetype))
    return next_field;
  if (!is_empty_class (basetype))
    {
      tree decl;
      CLASSTYPE_EMPTY_P (t) = 0;
      decl = build_decl (FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype));
      DECL_ARTIFICIAL (decl) = 1;
      DECL_IGNORED_P (decl) = 1;
      DECL_FIELD_CONTEXT (decl) = t;
      DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype);
      DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype);
      DECL_ALIGN (decl) = CLASSTYPE_ALIGN (basetype);
      DECL_USER_ALIGN (decl) = CLASSTYPE_USER_ALIGN (basetype);
      DECL_MODE (decl) = TYPE_MODE (basetype);
      DECL_FIELD_IS_BASE (decl) = 1;
      layout_nonempty_base_or_field (rli, decl, binfo, offsets);
      TREE_CHAIN (decl) = *next_field;
      *next_field = decl;
      next_field = &TREE_CHAIN (decl);
    }
  else
    {
      tree eoc;
      bool atend;
      eoc = round_up (rli_size_unit_so_far (rli),
		      CLASSTYPE_ALIGN_UNIT (basetype));
      atend = layout_empty_base (binfo, eoc, offsets);
      if (!BINFO_VIRTUAL_P (binfo) && CLASSTYPE_NEARLY_EMPTY_P (t))
	{
	  if (atend)
	    CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
	  else if (walk_subobject_offsets (basetype,
					   empty_base_at_nonzero_offset_p,
					   size_zero_node,
					   NULL,
					   NULL_TREE,
					   true))
	    {
	      if (abi_version_at_least (2))
		CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
	      else
		warning (OPT_Wabi,
			 "class %qT will be considered nearly empty in a "
			 "future version of GCC", t);
	    }
	}
    }
  record_subobject_offsets (binfo,
			    BINFO_OFFSET (binfo),
			    offsets,
			    false);
  return next_field;
}
static tree * build_base_field ( record_layout_info rli , tree binfo , splay_tree offsets , tree * next_field ) { tree t = rli -> t ; tree basetype = BINFO_TYPE ( binfo ) ; if ( ! COMPLETE_TYPE_P ( basetype ) ) return next_field ; if ( ! is_empty_class ( basetype ) ) { tree decl ; CLASSTYPE_EMPTY_P ( t ) = 0 ; decl = build_decl ( FIELD_DECL , NULL_TREE , CLASSTYPE_AS_BASE ( basetype ) ) ; DECL_ARTIFICIAL ( decl ) = 1 ; DECL_IGNORED_P ( decl ) = 1 ; DECL_FIELD_CONTEXT ( decl ) = t ; DECL_SIZE ( decl ) = CLASSTYPE_SIZE ( basetype ) ; DECL_SIZE_UNIT ( decl ) = CLASSTYPE_SIZE_UNIT ( basetype ) ; DECL_ALIGN ( decl ) = CLASSTYPE_ALIGN ( basetype ) ; DECL_USER_ALIGN ( decl ) = CLASSTYPE_USER_ALIGN ( basetype ) ; DECL_MODE ( decl ) = TYPE_MODE ( basetype ) ; DECL_FIELD_IS_BASE ( decl ) = 1 ; layout_nonempty_base_or_field ( rli , decl , binfo , offsets ) ; TREE_CHAIN ( decl ) = * next_field ; * next_field = decl ; next_field = & TREE_CHAIN ( decl ) ; } else { tree eoc ; bool atend ; eoc = round_up ( rli_size_unit_so_far ( rli ) , CLASSTYPE_ALIGN_UNIT ( basetype ) ) ; atend = layout_empty_base ( binfo , eoc , offsets ) ; if ( ! BINFO_VIRTUAL_P ( binfo ) && CLASSTYPE_NEARLY_EMPTY_P ( t ) ) { if ( atend ) CLASSTYPE_NEARLY_EMPTY_P ( t ) = 0 ; else if ( walk_subobject_offsets ( basetype , empty_base_at_nonzero_offset_p , size_zero_node , NULL , NULL_TREE , true ) ) { if ( abi_version_at_least ( 2 ) ) CLASSTYPE_NEARLY_EMPTY_P ( t ) = 0 ; else warning ( OPT_Wabi , " " " " , t ) ; } } } record_subobject_offsets ( binfo , BINFO_OFFSET ( binfo ) , offsets , false ) ; return next_field ; }
Layout the base given by BINFO in the class indicated by RLI.
Layout the base given by BINFO in the class indicated by RLI .
/* This error is now reported in xref_tag, thus giving better
       location information.  */ /* Place the base class.  */ /* The containing class is non-empty because it has a non-empty
	 base class.  */ /* Create the FIELD_DECL.  */ /* Try to place the field.  It may take more than one try if we
	 have a hard time placing the field without putting two
	 objects of the same type at the same address.  */ /* Add the new FIELD_DECL to the list of fields for T.  */ /* On some platforms (ARM), even empty classes will not be
	 byte-aligned.  */ /* A nearly-empty class "has no proper base class that is empty,
	 not morally virtual, and at an offset other than zero."  */ /* The check above (used in G++ 3.2) is insufficient because
	     an empty class placed at offset zero might itself have an
	     empty base at a nonzero offset.  */ /*offsets=*/ /*max_offset=*/ /*vbases_p=*/ /* We do not create a FIELD_DECL for empty base classes because
	 it might overlap some other field.  We want to be able to
	 create CONSTRUCTORs for the class by iterating over the
	 FIELD_DECLs, and the back end does not handle overlapping
	 FIELD_DECLs.  */ /* An empty virtual base causes a class to be non-empty
	 -- but in that case we do not need to clear CLASSTYPE_EMPTY_P
	 here because that was already done when the virtual table
	 pointer was created.  */ /* Record the offsets of BINFO and its base subobjects.  */ /*is_data_member=*/