aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-12-16 00:17:40 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2020-12-19 20:39:04 +0100
commite9e4ddfc5abbf9ee5e657d626264cef89f10b4c3 (patch)
tree27db000303acbbfe2ddbd905428e3a5485a67081 /gcc/dwarf2out.c
parent9032d2b2414ed22e53a9980a51b835d3caf83c48 (diff)
downloadgcc-e9e4ddfc5abbf9ee5e657d626264cef89f10b4c3.zip
gcc-e9e4ddfc5abbf9ee5e657d626264cef89f10b4c3.tar.gz
gcc-e9e4ddfc5abbf9ee5e657d626264cef89f10b4c3.tar.bz2
d: Fix ICE in in force_decl_die, at dwarf2out.c with -gdwarf-2 -gstrict-dwarf [PR98067]
Manifest constants in D are represented as CONST_DECLs, which can be imported from one module to another. However, when compiling on strict dwarf2 targets such as *-*-darwin10, importing CONST_DECLs cannot be represented in debug as D did not exist as an AT_language until dwarf3, and the only available fallback being DW_LANG_C. As CONST_DECLs are treated as enumerators in C, and not outputted individually in gen_decl_die, this causes an internal error in force_decl_die to occur. To handle this, similar to other places in dwarf2out, if a CONST_DECL is seen in dwarf2out_imported_module_or_decl_1, then we simply return early if the language is not one of Ada, D, or Fortran. gcc/ChangeLog: PR d/98067 * dwarf2out.c (dwarf2out_imported_module_or_decl_1): Handle CONST_DECL only if is_fortran, is_ada, or is_dlang. gcc/testsuite/ChangeLog: PR d/98067 * gdc.dg/debug/debug.exp: New test. * gdc.dg/debug/dwarf2/dwarf2.exp: New test. * gdc.dg/debug/dwarf2/imports/pr98067.d: New test. * gdc.dg/debug/dwarf2/langdw2.d: New test. * gdc.dg/debug/dwarf2/langdw3.d: New test. * gdc.dg/debug/dwarf2/pr98067.d: New test. * gdc.dg/debug/trivial.d: New test.
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 0baa056..027f327 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -26705,6 +26705,13 @@ dwarf2out_imported_module_or_decl_1 (tree decl,
gen_type_die_for_member (type, decl,
get_context_die (TYPE_CONTEXT (type)));
}
+ if (TREE_CODE (decl) == CONST_DECL)
+ {
+ /* Individual enumerators of an enum type do not get output here
+ (see gen_decl_die), so we cannot call force_decl_die. */
+ if (!is_fortran () && !is_ada () && !is_dlang ())
+ return;
+ }
if (TREE_CODE (decl) == NAMELIST_DECL)
at_import_die = gen_namelist_decl (DECL_NAME (decl),
get_context_die (DECL_CONTEXT (decl)),