diff options
author | Jason Merrill <merrill@gnu.org> | 1996-11-20 20:36:53 +0000 |
---|---|---|
committer | Jason Merrill <merrill@gnu.org> | 1996-11-20 20:36:53 +0000 |
commit | 88dad22845a4a1a81b1c49fa1555e0ab32af44bc (patch) | |
tree | 873e19747c9af42b9faae8b175ee7f5fcbe217a4 /gcc | |
parent | d2872d37e9f153148d58c0dd6c4ce6456ef0a595 (diff) | |
download | gcc-88dad22845a4a1a81b1c49fa1555e0ab32af44bc.zip gcc-88dad22845a4a1a81b1c49fa1555e0ab32af44bc.tar.gz gcc-88dad22845a4a1a81b1c49fa1555e0ab32af44bc.tar.bz2 |
x
From-SVN: r13209
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-decl.c | 4 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 67 | ||||
-rw-r--r-- | gcc/toplev.c | 13 | ||||
-rw-r--r-- | gcc/varasm.c | 4 |
4 files changed, 63 insertions, 25 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9347939..a3c8e29 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1324,6 +1324,10 @@ pushtag (name, type) tagged type. */ TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type)); + + /* An approximation for now, so we can tell this is a function-scope tag. + This will be updated in poplevel. */ + TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type)); } /* Handle when a new declaration NEWDECL diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 6d0e84b..0beb780 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5793,18 +5793,16 @@ add_bit_size_attribute (die, decl) (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl))); } -/* If the compiled language is GNU C, then add a 'prototyped' +/* If the compiled language is ANSI C, then add a 'prototyped' attribute, if arg types are given for the parameters of a function. */ inline void add_prototyped_attribute (die, func_type) register dw_die_ref die; register tree func_type; { - if ((strcmp (language_string, "GNU C") == 0) - && (TYPE_ARG_TYPES (func_type) != NULL)) - { - add_AT_flag (die, DW_AT_prototyped, 0); - } + if (get_AT_unsigned (comp_unit_die, DW_AT_language) == DW_LANG_C89 + && TYPE_ARG_TYPES (func_type) != NULL) + add_AT_flag (die, DW_AT_prototyped, 1); } @@ -5893,6 +5891,11 @@ scope_die_for (t, context_die) register tree containing_scope; register unsigned long i; + /* Function-local tags and functions get stuck in limbo until they are + fixed up by decls_for_scope. */ + if (context_die == NULL) + return NULL; + /* Walk back up the declaration tree looking for a place to define this type. */ if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') @@ -6037,7 +6040,7 @@ decl_start_label (decl) /* These routines generate the internnal representation of the DIE's for the compilation unit. Debugging information is collected by walking - the declaration trees passed in from dwarf2out_file_scope_decl(). */ + the declaration trees passed in from dwarf2out_decl(). */ static void gen_array_type_die (type, context_die) @@ -6489,6 +6492,10 @@ gen_subprogram_die (decl, context_die) fp_loc = new_loc_descr (DW_OP_reg0 + fp_reg); add_AT_loc (subr_die, DW_AT_frame_base, fp_loc); + if (current_function_needs_context) + add_AT_loc (subr_die, DW_AT_static_link, + loc_descriptor (lookup_static_chain (decl))); + #ifdef DWARF_GNU_EXTENSIONS ASM_GENERATE_INTERNAL_LABEL (label_id, BODY_BEGIN_LABEL, current_funcdef_number); @@ -7325,13 +7332,28 @@ decls_for_scope (stmt, context_die, depth) next_block_number++; } - /* Output the DIEs to represent all of the data objects, functions, - typedefs, and tagged types declared directly within this block but not - within any nested sub-blocks. */ + /* Output the DIEs to represent all of the data objects and typedefs + declared directly within this block but not within any nested + sub-blocks. Also, nested function and tag DIEs have been + generated with a parent of NULL; fix that up now. */ for (decl = BLOCK_VARS (stmt); decl != NULL; decl = TREE_CHAIN (decl)) { - gen_decl_die (decl, context_die); + if (TREE_CODE (decl) == FUNCTION_DECL) + { + register dw_die_ref die = lookup_decl_die (decl); + add_child_die (context_die, die); + } + else if (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)) + { + register dw_die_ref die = lookup_type_die (TREE_TYPE (decl)); + if (die) + add_child_die (context_die, die); + else + gen_decl_die (decl, context_die); + } + else + gen_decl_die (decl, context_die); } /* Output the DIEs to represent all sub-blocks (and the items declared @@ -7478,10 +7500,11 @@ gen_decl_die (decl, context_die) /***************** Debug Information Generation Hooks ***********************/ void -dwarf2out_file_scope_decl (decl, set_finalizing) +dwarf2out_decl (decl) register tree decl; - register int set_finalizing; { + register dw_die_ref context_die = comp_unit_die; + if (TREE_CODE (decl) == ERROR_MARK) { return; @@ -7544,6 +7567,13 @@ dwarf2out_file_scope_decl (decl, set_finalizing) { return; } + + /* If we're a nested function, initially use a parent of NULL; if we're + a plain function, this will be fixed up in decls_for_scope. If + we're a method, it will be ignored, since we already have a DIE. */ + if (decl_function_context (decl)) + context_die = NULL; + break; case VAR_DECL: @@ -7574,17 +7604,22 @@ dwarf2out_file_scope_decl (decl, set_finalizing) if (DECL_SOURCE_LINE (decl) == 0) return; - /* If we are in terse mode, don't generate any DIEs to represent any - actual typedefs. */ + /* If we are in terse mode, don't generate any DIEs for types. */ if (debug_info_level <= DINFO_LEVEL_TERSE) return; + + /* If we're a function-scope tag, initially use a parent of NULL; + this will be fixed up in decls_for_scope. */ + if (decl_function_context (decl)) + context_die = NULL; + break; default: return; } - gen_decl_die (decl, comp_unit_die); + gen_decl_die (decl, context_die); if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL) diff --git a/gcc/toplev.c b/gcc/toplev.c index 6a67d03..62e66d9 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2538,7 +2538,7 @@ compile_file (name) if (write_symbols == DWARF2_DEBUG && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) - TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 1)); + TIMEVAR (symout_time, dwarf2out_decl (decl)); #endif } } @@ -2782,9 +2782,8 @@ rest_of_type_compilation (type, toplev) TIMEVAR (symout_time, dwarfout_file_scope_decl (TYPE_STUB_DECL (type), 0)); #endif #ifdef DWARF2_DEBUGGING_INFO - /* Don't write out function-scope types here. */ - if (write_symbols == DWARF2_DEBUG && toplev) - TIMEVAR (symout_time, dwarf2out_file_scope_decl (TYPE_STUB_DECL (type), 0)); + if (write_symbols == DWARF2_DEBUG) + TIMEVAR (symout_time, dwarf2out_decl (TYPE_STUB_DECL (type))); #endif } @@ -2900,7 +2899,7 @@ rest_of_compilation (decl) if (write_symbols == DWARF2_DEBUG) { set_decl_abstract_flags (decl, 1); - TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0)); + TIMEVAR (symout_time, dwarf2out_decl (decl)); set_decl_abstract_flags (decl, 0); } #endif @@ -2934,7 +2933,7 @@ rest_of_compilation (decl) if (write_symbols == DWARF2_DEBUG) { set_decl_abstract_flags (decl, 1); - TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0)); + TIMEVAR (symout_time, dwarf2out_decl (decl)); set_decl_abstract_flags (decl, 0); } #endif @@ -3431,7 +3430,7 @@ rest_of_compilation (decl) #ifdef DWARF2_DEBUGGING_INFO if (write_symbols == DWARF2_DEBUG) - TIMEVAR (symout_time, dwarf2out_file_scope_decl (decl, 0)); + TIMEVAR (symout_time, dwarf2out_decl (decl)); #endif exit_rest_of_compilation: diff --git a/gcc/varasm.c b/gcc/varasm.c index d746b71..9490238 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1183,7 +1183,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) #ifdef DWARF2_DEBUGGING_INFO if (write_symbols == DWARF2_DEBUG && top_level && DECL_CONTEXT (decl)) - dwarf2out_file_scope_decl (decl, 0); + dwarf2out_decl (decl); #endif } @@ -1316,7 +1316,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) #ifdef DWARF2_DEBUGGING_INFO if (write_symbols == DWARF2_DEBUG && top_level && DECL_CONTEXT (decl)) - dwarf2out_file_scope_decl (decl, 0); + dwarf2out_decl (decl); #endif /* Only output DWARF debugging information for record-scope variables |