diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-07-31 10:01:25 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-07-31 10:01:25 +0200 |
commit | 1e1d38871b1b64c4480e08179ebce9efc2161a01 (patch) | |
tree | 5d7741a5fa35893c436c49fabebc382a2f344042 /gcc | |
parent | b3e200e1354de45b09c18ee4260d6b7e8d2db51e (diff) | |
download | gcc-1e1d38871b1b64c4480e08179ebce9efc2161a01.zip gcc-1e1d38871b1b64c4480e08179ebce9efc2161a01.tar.gz gcc-1e1d38871b1b64c4480e08179ebce9efc2161a01.tar.bz2 |
re PR debug/36278 (ICE with typedef void in namespace and using the defined type in another when compiling with "-g")
PR debug/36278
* dwarf2out.c (get_context_die): New function.
(force_decl_die, force_type_die): Use it.
(dwarf2out_imported_module_or_decl): Likewise. If base_type_die
returns NULL, force generation of DW_TAG_typedef and put that into
DW_AT_import.
* g++.dg/debug/namespace2.C: New test.
From-SVN: r138361
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 86 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/debug/namespace2.C | 8 |
4 files changed, 60 insertions, 46 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57a4f16..49799a8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2008-07-31 Jakub Jelinek <jakub@redhat.com> + PR debug/36278 + * dwarf2out.c (get_context_die): New function. + (force_decl_die, force_type_die): Use it. + (dwarf2out_imported_module_or_decl): Likewise. If base_type_die + returns NULL, force generation of DW_TAG_typedef and put that into + DW_AT_import. + PR preprocessor/36649 * c-pch.c (c_common_read_pch): Save and restore line_table->trace_includes across PCH restore. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index f553f2e..dbf5105 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -14068,6 +14068,22 @@ is_redundant_typedef (const_tree decl) return 0; } +/* Returns the DIE for a context. */ + +static inline dw_die_ref +get_context_die (tree context) +{ + if (context) + { + /* Find die that represents this context. */ + if (TYPE_P (context)) + return force_type_die (context); + else + return force_decl_die (context); + } + return comp_unit_die; +} + /* Returns the DIE for decl. A DIE will always be returned. */ static dw_die_ref @@ -14079,18 +14095,7 @@ force_decl_die (tree decl) decl_die = lookup_decl_die (decl); if (!decl_die) { - dw_die_ref context_die; - tree decl_context = DECL_CONTEXT (decl); - if (decl_context) - { - /* Find die that represents this context. */ - if (TYPE_P (decl_context)) - context_die = force_type_die (decl_context); - else - context_die = force_decl_die (decl_context); - } - else - context_die = comp_unit_die; + dw_die_ref context_die = get_context_die (DECL_CONTEXT (decl)); decl_die = lookup_decl_die (decl); if (decl_die) @@ -14145,16 +14150,7 @@ force_type_die (tree type) type_die = lookup_type_die (type); if (!type_die) { - dw_die_ref context_die; - if (TYPE_CONTEXT (type)) - { - if (TYPE_P (TYPE_CONTEXT (type))) - context_die = force_type_die (TYPE_CONTEXT (type)); - else - context_die = force_decl_die (TYPE_CONTEXT (type)); - } - else - context_die = comp_unit_die; + dw_die_ref context_die = get_context_die (TYPE_CONTEXT (type)); type_die = modified_type_die (type, TYPE_READONLY (type), TYPE_VOLATILE (type), context_die); @@ -14476,16 +14472,11 @@ dwarf2out_imported_module_or_decl (tree decl, tree context) /* Get the scope die for decl context. Use comp_unit_die for global module or decl. If die is not found for non globals, force new die. */ - if (!context) - scope_die = comp_unit_die; - else if (TYPE_P (context)) - { - if (!should_emit_struct_debug (context, DINFO_USAGE_DIR_USE)) - return; - scope_die = force_type_die (context); - } - else - scope_die = force_decl_die (context); + if (context + && TYPE_P (context) + && !should_emit_struct_debug (context, DINFO_USAGE_DIR_USE)) + return; + scope_die = get_context_die (context); /* For TYPE_DECL or CONST_DECL, lookup TREE_TYPE. */ if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL) @@ -14494,6 +14485,16 @@ dwarf2out_imported_module_or_decl (tree decl, tree context) at_import_die = base_type_die (TREE_TYPE (decl)); else at_import_die = force_type_die (TREE_TYPE (decl)); + /* For namespace N { typedef void T; } using N::T; base_type_die + returns NULL, but DW_TAG_imported_declaration requires + the DW_AT_import tag. Force creation of DW_TAG_typedef. */ + if (!at_import_die) + { + gcc_assert (TREE_CODE (decl) == TYPE_DECL); + gen_typedef_die (decl, get_context_die (DECL_CONTEXT (decl))); + at_import_die = lookup_type_die (TREE_TYPE (decl)); + gcc_assert (at_import_die); + } } else { @@ -14505,21 +14506,14 @@ dwarf2out_imported_module_or_decl (tree decl, tree context) if (TREE_CODE (decl) == FIELD_DECL) { tree type = DECL_CONTEXT (decl); - dw_die_ref type_context_die; - if (TYPE_CONTEXT (type)) - if (TYPE_P (TYPE_CONTEXT (type))) - { - if (!should_emit_struct_debug (TYPE_CONTEXT (type), - DINFO_USAGE_DIR_USE)) - return; - type_context_die = force_type_die (TYPE_CONTEXT (type)); - } - else - type_context_die = force_decl_die (TYPE_CONTEXT (type)); - else - type_context_die = comp_unit_die; - gen_type_die_for_member (type, decl, type_context_die); + if (TYPE_CONTEXT (type) + && TYPE_P (TYPE_CONTEXT (type)) + && !should_emit_struct_debug (TYPE_CONTEXT (type), + DINFO_USAGE_DIR_USE)) + return; + gen_type_die_for_member (type, decl, + get_context_die (TYPE_CONTEXT (type))); } at_import_die = force_decl_die (decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8534f8c..0df56e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,11 @@ PR debug/36278 * g++.dg/debug/namespace2.C: New test. + * gcc.dg/pch/cpp-3.c: New test. + * gcc.dg/pch/cpp-3.hs: New file. + * gcc.dg/pch/cpp-3a.h: New file. + * gcc.dg/pch/cpp-3b.h: New file. + 2008-07-30 Eric Botcazou <ebotcazou@adacore.com> * gnat.dg/boolean_expr.ad[sb]: New test. diff --git a/gcc/testsuite/g++.dg/debug/namespace2.C b/gcc/testsuite/g++.dg/debug/namespace2.C new file mode 100644 index 0000000..f70bc8f --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/namespace2.C @@ -0,0 +1,8 @@ +// PR debug/36278 +// { dg-do compile } + +namespace N +{ + typedef void T; +} +using N::T; |