if (TYPE_SIZE (type))
{
register tree link;
+ TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
for (link = TYPE_FIELDS (type);
link != NULL; link = TREE_CHAIN (link))
register dw_die_ref context_die;
{
register dw_die_ref type_die = lookup_type_die (type);
+ register dw_die_ref scope_die = 0;
+ register int nested = 0;
if (type_die && ! TYPE_SIZE (type))
return;
- else if (! type_die
- || (TYPE_CONTEXT (type)
- && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't'))
+
+ if (TYPE_CONTEXT (type)
+ && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't')
+ nested = 1;
+
+ if (! type_die || nested)
+ scope_die = scope_die_for (type, context_die);
+
+ if (! type_die || (nested && scope_die == comp_unit_die))
/* First occurrence of type or toplevel definition of nested class. */
{
register dw_die_ref old_die = type_die;
type_die = new_die (TREE_CODE (type) == RECORD_TYPE
? DW_TAG_structure_type : DW_TAG_union_type,
- scope_die_for (type, context_die));
+ scope_die);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
if (old_die)
/* If this type has been completed, then give it a byte_size attribute and
then give a list of members. */
- if (TYPE_SIZE (type))
+ if (TYPE_SIZE (type)
+ /* If we're getting a reference to one nested class from another
+ nested class, don't recurse. */
+ && ! (nested && scope_die != context_die
+ && scope_die == lookup_type_die (TYPE_CONTEXT (type))))
{
/* Prevent infinite recursion in cases where the type of some member of
this type is expressed in terms of this type itself. */
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
- if (TREE_CODE (type) == ENUMERAL_TYPE)
+ /* If this is a nested type whose containing class hasn't been
+ written out yet, writing it out will cover this one, too. */
+ if (TYPE_CONTEXT (type)
+ && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't'
+ && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
+ gen_type_die (TYPE_CONTEXT (type), context_die);
+ else if (TREE_CODE (type) == ENUMERAL_TYPE)
gen_enumeration_type_die (type, context_die);
else
gen_struct_or_union_type_die (type, context_die);
/* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
- it up if it is ever completed. */
- if (TYPE_SIZE (type) == NULL_TREE)
- return;
- break;
+ it up if it is ever completed. gen_*_type_die will set it for us
+ when appropriate. */
+ return;
case VOID_TYPE:
case INTEGER_TYPE:
In both cases, all we do is lay out the decl,
and we do it *after* the record is laid out. */
- if (TREE_STATIC (field))
+ if (TREE_CODE (field) == VAR_DECL)
{
pending_statics = tree_cons (NULL_TREE, field, pending_statics);
continue;
TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev));
#endif
#ifdef DWARF_DEBUGGING_INFO
- /* If this is a file-scope type or a class-scope type
- for which the containing class has already been completed, write it
- out now to avoid ordering headaches with member functions. */
- if (write_symbols == DWARF_DEBUG
- && (TYPE_CONTEXT (type) == NULL_TREE
- || TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
+ /* Don't write out function-scope types here. */
+ if (write_symbols == DWARF_DEBUG && toplev)
TIMEVAR (symout_time, dwarfout_file_scope_decl (TYPE_STUB_DECL (type), 0));
#endif
}
/* Struct in C, or record in Pascal. */
/* Special fields:
- TYPE_FIELDS chain of FIELD_DECLs for the fields of the struct.
+ TYPE_FIELDS chain of FIELD_DECLs for the fields of the struct,
+ and VAR_DECLs, TYPE_DECLs and CONST_DECLs for record-scope variables,
+ types and enumerators.
A few may need to be added for Pascal. */
/* See the comment above, before ENUMERAL_TYPE, for how
forward references to struct tags are handled in C. */
this declaration has its scope. For FIELD_DECLs, this is the
RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node that the field
is a member of. For VAR_DECL, PARM_DECL, FUNCTION_DECL, LABEL_DECL,
- and CONST_DECL nodes, this points to the FUNCTION_DECL for the
- containing function, or else yields NULL_TREE if the given decl
- has "file scope".
+ and CONST_DECL nodes, this points to either the FUNCTION_DECL for the
+ containing function, the RECORD_TYPE or UNION_TYPE for the containing
+ type, or NULL_TREE if the given decl has "file scope".
DECL_ABSTRACT_ORIGIN, if non-NULL, points to the original (abstract)
..._DECL node of which this decl is an (inlined or template expanded)
instance.
/* For FIELD_DECLs, this is the
RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node that the field is
a member of. For VAR_DECL, PARM_DECL, FUNCTION_DECL, LABEL_DECL,
- and CONST_DECL nodes, this points to the FUNCTION_DECL for the
- containing function, or else yields NULL_TREE if the given decl has "file scope". */
+ and CONST_DECL nodes, this points to either the FUNCTION_DECL for the
+ containing function, the RECORD_TYPE or UNION_TYPE for the containing
+ type, or NULL_TREE if the given decl has "file scope". */
#define DECL_CONTEXT(NODE) ((NODE)->decl.context)
#define DECL_FIELD_CONTEXT(NODE) ((NODE)->decl.context)
/* In a DECL this is the field where configuration dependent machine
&& (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
sdbout_symbol (decl, 0);
#endif
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG && top_level
+ && DECL_CONTEXT (decl))
+ dwarfout_file_scope_decl (decl, 0);
+#endif
}
- /* Don't output any DWARF debugging information for variables here.
- In the case of local variables, the information for them is output
- when we do our recursive traversal of the tree representation for
- the entire containing function. In the case of file-scope variables,
- we output information for all of them at the very end of compilation
- while we are doing our final traversal of the chain of file-scope
- declarations. */
+ /* Only output DWARF debugging information for record-scope variables
+ here. In the case of function-scope variables, the information
+ for them is output when we do our recursive traversal of the tree
+ representation for the entire containing function. In the case of
+ file-scope variables, we output information for all of them at the
+ very end of compilation while we are doing our final traversal of
+ the chain of file-scope declarations. */
return;
}
&& (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
sdbout_symbol (decl, 0);
#endif
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG && top_level
+ && DECL_CONTEXT (decl))
+ dwarfout_file_scope_decl (decl, 0);
+#endif
- /* Don't output any DWARF debugging information for variables here.
- In the case of local variables, the information for them is output
- when we do our recursive traversal of the tree representation for
- the entire containing function. In the case of file-scope variables,
- we output information for all of them at the very end of compilation
- while we are doing our final traversal of the chain of file-scope
- declarations. */
+ /* Only output DWARF debugging information for record-scope variables
+ here. In the case of function-scope variables, the information
+ for them is output when we do our recursive traversal of the tree
+ representation for the entire containing function. In the case of
+ file-scope variables, we output information for all of them at the
+ very end of compilation while we are doing our final traversal of
+ the chain of file-scope declarations. */
#if 0 /* ??? We should either delete this or add a comment describing what
it was intended to do and why we shouldn't delete it. */