public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9067] dwarf2: ICE with local class in unused function [PR97918]
@ 2020-11-24 17:58 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2020-11-24 17:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:196716c10bcd4074c404cc8f13bf8d9b31c76238

commit r9-9067-g196716c10bcd4074c404cc8f13bf8d9b31c76238
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Nov 20 15:20:45 2020 -0500

    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.

Diff:
---
 gcc/dwarf2out.c                          |  6 +++---
 gcc/testsuite/g++.dg/debug/localclass2.C | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3c6833419c6..c18a325d760 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -32147,13 +32147,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 00000000000..9897eec5d2d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/localclass2.C
@@ -0,0 +1,24 @@
+// PR c++/97918
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target lto }
+// { dg-additional-options "-g -O -flto" }
+
+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
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-24 17:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 17:58 [gcc r9-9067] dwarf2: ICE with local class in unused function [PR97918] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).