contrib/gcc-4.7/gcc/cp/class.c
/* Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE.
   (For a secondary vtable for B-in-D, CLASS_TYPE should be D, not B.)
   Use NAME for the name of the vtable, and VTABLE_TYPE for its type.  */
Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE.
(For a secondary vtable for B-in-D, CLASS_TYPE should be D, not B.)
Use NAME for the name of the vtable, and VTABLE_TYPE for its type.
Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE . ( For a secondary vtable for B - in - D CLASS_TYPE should be D not B . ) Use NAME for the name of the vtable and VTABLE_TYPE for its type .
static tree
build_vtable (tree class_type, tree name, tree vtable_type)
{
  tree decl;
  decl = build_lang_decl (VAR_DECL, name, vtable_type);
  SET_DECL_ASSEMBLER_NAME (decl, name);
  DECL_CONTEXT (decl) = class_type;
  DECL_ARTIFICIAL (decl) = 1;
  TREE_STATIC (decl) = 1;
  TREE_READONLY (decl) = 1;
  DECL_VIRTUAL_P (decl) = 1;
  DECL_ALIGN (decl) = TARGET_VTABLE_ENTRY_ALIGN;
  DECL_VTABLE_OR_VTT_P (decl) = 1;
  DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
			   DECL_ALIGN (decl));
  set_linkage_according_to_type (class_type, decl);
  DECL_EXTERNAL (decl) = 1;
  DECL_NOT_REALLY_EXTERN (decl) = 1;
  DECL_IGNORED_P (decl) = 1;
  return decl;
}
static tree build_vtable ( tree class_type , tree name , tree vtable_type ) { tree decl ; decl = build_lang_decl ( VAR_DECL , name , vtable_type ) ; SET_DECL_ASSEMBLER_NAME ( decl , name ) ; DECL_CONTEXT ( decl ) = class_type ; DECL_ARTIFICIAL ( decl ) = 1 ; TREE_STATIC ( decl ) = 1 ; TREE_READONLY ( decl ) = 1 ; DECL_VIRTUAL_P ( decl ) = 1 ; DECL_ALIGN ( decl ) = TARGET_VTABLE_ENTRY_ALIGN ; DECL_VTABLE_OR_VTT_P ( decl ) = 1 ; DECL_ALIGN ( decl ) = MAX ( TYPE_ALIGN ( double_type_node ) , DECL_ALIGN ( decl ) ) ; set_linkage_according_to_type ( class_type , decl ) ; DECL_EXTERNAL ( decl ) = 1 ; DECL_NOT_REALLY_EXTERN ( decl ) = 1 ; DECL_IGNORED_P ( decl ) = 1 ; return decl ; }
Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE.
Create a VAR_DECL for a primary or secondary vtable for CLASS_TYPE .
/* vtable names are already mangled; give them their DECL_ASSEMBLER_NAME
     now to avoid confusion in mangle_decl.  */ /* At one time the vtable info was grabbed 2 words at a time.  This
     fails on sparc unless you have 8-byte alignment.  (tiemann) */ /* The vtable has not been defined -- yet.  */ /* Mark the VAR_DECL node representing the vtable itself as a
     "gratuitous" one, thereby forcing dwarfout.c to ignore it.  It
     is rather important that such things be ignored because any
     effort to actually generate DWARF for them will run into
     trouble when/if we encounter code like:

     #pragma interface
     struct S { virtual void member (); };

     because the artificial declaration of the vtable itself (as
     manufactured by the g++ front end) will say that the vtable is
     a static member of `S' but only *after* the debug output for
     the definition of `S' has already been output.  This causes
     grief because the DWARF entry for the definition of the vtable
     will try to refer back to an earlier *declaration* of the
     vtable as a static member of `S' and there won't be one.  We
     might be able to arrange to have the "vtable static member"
     attached to the member list for `S' before the debug info for
     `S' get written (which would solve the problem) but that would
     require more intrusive changes to the g++ front end.  */