aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-11-20 15:20:45 -0500
committerJason Merrill <jason@redhat.com>2020-11-20 16:43:25 -0500
commit89d9c634dc5c10b499c23297ef70133066946790 (patch)
treea0e5fe1224bc29a3697b75b65134a0758323455c /gcc
parent27c5416fc8a4c2b33a0d6b6a26da2518791e0464 (diff)
downloadgcc-89d9c634dc5c10b499c23297ef70133066946790.zip
gcc-89d9c634dc5c10b499c23297ef70133066946790.tar.gz
gcc-89d9c634dc5c10b499c23297ef70133066946790.tar.bz2
dwarf2: ICE with local class in unused function [PR97918]
Here, since we only mention bar<B>, we never emit debug information for it. But we do emit debug information for H<J>::h, so we need to refer to the debug info for bar<B>::J even though there is no bar<B>. We deal with this sort of thing in dwarf2out with the limbo_die_list; parentless dies like J get attached to the CU at EOF. But here, we were flushing the limbo list, then generating the template argument DIE for H<J> that refers to J, which adds J to the limbo list, too late to be flushed. So let's flush a little later. gcc/ChangeLog: PR c++/97918 * dwarf2out.c (dwarf2out_early_finish): flush_limbo_die_list after gen_scheduled_generic_parms_dies. gcc/testsuite/ChangeLog: PR c++/97918 * g++.dg/debug/localclass2.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/dwarf2out.c6
-rw-r--r--gcc/testsuite/g++.dg/debug/localclass2.C23
2 files changed, 26 insertions, 3 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ea2a22a..07e1a92 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -32169,13 +32169,13 @@ dwarf2out_early_finish (const char *filename)
emit full debugging info for them. */
retry_incomplete_types ();
+ gen_scheduled_generic_parms_dies ();
+ gen_remaining_tmpl_value_param_die_attribute ();
+
/* The point here is to flush out the limbo list so that it is empty
and we don't need to stream it for LTO. */
flush_limbo_die_list ();
- gen_scheduled_generic_parms_dies ();
- gen_remaining_tmpl_value_param_die_attribute ();
-
/* Add DW_AT_linkage_name for all deferred DIEs. */
for (limbo_die_node *node = deferred_asm_name; node; node = node->next)
{
diff --git a/gcc/testsuite/g++.dg/debug/localclass2.C b/gcc/testsuite/g++.dg/debug/localclass2.C
new file mode 100644
index 0000000..3dd7cae
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/localclass2.C
@@ -0,0 +1,23 @@
+// PR c++/97918
+// { dg-additional-options "-g -O -flto" }
+// { dg-do compile { target c++11 } }
+
+namespace { class A {}; }
+class B {};
+template <typename T> struct H {
+ constexpr static unsigned h = 0;
+};
+
+template <typename T> A bar ()
+{
+ struct J {
+ static void foo();
+ };
+ H<J>();
+ return A ();
+}
+
+void fn ()
+{
+ bar<B>; // only mentions the function
+}