diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-12-16 00:17:40 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-12-19 20:39:04 +0100 |
commit | e9e4ddfc5abbf9ee5e657d626264cef89f10b4c3 (patch) | |
tree | 27db000303acbbfe2ddbd905428e3a5485a67081 /gcc | |
parent | 9032d2b2414ed22e53a9980a51b835d3caf83c48 (diff) | |
download | gcc-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')
-rw-r--r-- | gcc/dwarf2out.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/debug.exp | 28 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/dwarf2/dwarf2.exp | 31 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/dwarf2/imports/pr98067.d | 3 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/dwarf2/langdw2.d | 7 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/dwarf2/langdw3.d | 6 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/dwarf2/pr98067.d | 6 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/debug/trivial.d | 6 |
8 files changed, 94 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)), diff --git a/gcc/testsuite/gdc.dg/debug/debug.exp b/gcc/testsuite/gdc.dg/debug/debug.exp new file mode 100644 index 0000000..1607c4d --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/debug.exp @@ -0,0 +1,28 @@ +# Copyright (C) 2020 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib gdc-dg.exp + +# Initialize `dg'. +dg-init + +# Main loop. +gcc-dg-debug-runtest gdc_target_compile trivial.d [list -O -O3] \ + [lsort [glob -nocomplain $srcdir/$subdir/*.d]] + +# All done. +dg-finish diff --git a/gcc/testsuite/gdc.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/gdc.dg/debug/dwarf2/dwarf2.exp new file mode 100644 index 0000000..c81afd0 --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/dwarf2/dwarf2.exp @@ -0,0 +1,31 @@ +# Copyright (C) 2020 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib gdc-dg.exp + +# Main loop. +set comp_output [gdc_target_compile \ + "$srcdir/$subdir/../trivial.d" "trivial.S" assembly \ + "additional_flags=-gdwarf"] +if { ! [string match "*: target system does not support the * debug format*" \ + $comp_output] } { + remove-build-file "trivial.S" + gdc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.d ] ] "" "-gdwarf" +} + +# All done. +dg-finish diff --git a/gcc/testsuite/gdc.dg/debug/dwarf2/imports/pr98067.d b/gcc/testsuite/gdc.dg/debug/dwarf2/imports/pr98067.d new file mode 100644 index 0000000..d740d71 --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/dwarf2/imports/pr98067.d @@ -0,0 +1,3 @@ +module imports.pr98067; + +enum MAP_ANON = 0x10; diff --git a/gcc/testsuite/gdc.dg/debug/dwarf2/langdw2.d b/gcc/testsuite/gdc.dg/debug/dwarf2/langdw2.d new file mode 100644 index 0000000..61c3927 --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/dwarf2/langdw2.d @@ -0,0 +1,7 @@ +// DW_LANG_D is not available in dwarf2, so we should produce DW_LANG_C (0x2) +// as AT_language. +// { dg-do compile } +// { dg-options "-gdwarf-2 -gstrict-dwarf -dA" } +// { dg-final { scan-assembler "0x2\[^\n\r\]*AT_language" } } + +module langdw2; diff --git a/gcc/testsuite/gdc.dg/debug/dwarf2/langdw3.d b/gcc/testsuite/gdc.dg/debug/dwarf2/langdw3.d new file mode 100644 index 0000000..7bdc68c --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/dwarf2/langdw3.d @@ -0,0 +1,6 @@ +// We should produce DW_LANG_D (0x13) as AT_language. +// { dg-do compile } +// { dg-options "-gdwarf-3 -dA" } +// { dg-final { scan-assembler "0x13\[^\n\r\]*AT_language" } } + +module langdw3; diff --git a/gcc/testsuite/gdc.dg/debug/dwarf2/pr98067.d b/gcc/testsuite/gdc.dg/debug/dwarf2/pr98067.d new file mode 100644 index 0000000..4beb268 --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/dwarf2/pr98067.d @@ -0,0 +1,6 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98067 +// { dg-options "-gdwarf-2 -gstrict-dwarf -I $srcdir/gdc.dg/debug/dwarf2" } +// { dg-do compile } +module pr98067; + +import imports.pr98067 : MAP_ANON; diff --git a/gcc/testsuite/gdc.dg/debug/trivial.d b/gcc/testsuite/gdc.dg/debug/trivial.d new file mode 100644 index 0000000..dab2b68 --- /dev/null +++ b/gcc/testsuite/gdc.dg/debug/trivial.d @@ -0,0 +1,6 @@ +/* { dg-do run } */ + +int main() +{ + return 0; +} |