https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108772

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #2)
> (In reply to Jakub Jelinek from comment #1)
> > Does firefox really use -fimplicit-constexpr and -g1?
> 
> Yes. Note the former option is used since gcc12:
> https://bugzilla.mozilla.org/show_bug.cgi?id=1754752

Note 'decl' is <namespace_decl 0x7ffff60d1260 std> for me.  For dwarf2
we return comp_unit_die () for this, but for -g1 we run into

    case NAMESPACE_DECL:
    case IMPORTED_DECL:
      if (debug_info_level <= DINFO_LEVEL_TERSE)
        return;

so maybe for force_decl_die we want to do the same or alternatively
for get_context_die () allow force_decl_die to "fail" and force one
for the next up context up to comp_unit_die ()?

OTOH, we run into this for a limbo entry that in the end likely will
not get any DIE at -g1 anyway, so "forcing" a context via get_context_die
is possibly excessive as well.

So I think the actual bug is that we created a DIE for __tag when -g1
doesn't want a DIE for its ultimate context.

Alternative make force_decl_die honor the dwarf2out_decl reality like
with

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1f39df3b1e2..bd2c9444ff3 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -26742,7 +26742,8 @@ force_decl_die (tree decl)
          break;

        case NAMESPACE_DECL:
-         if (dwarf_version >= 3 || !dwarf_strict)
+         if (debug_info_level > DINFO_LEVEL_TERSE
+             && (dwarf_version >= 3 || !dwarf_strict))
            dwarf2out_decl (decl);
          else
            /* DWARF2 has neither DW_TAG_module, nor DW_TAG_namespace.  */

in which case we'll put the function decl context in the CU DIE rather
than in a namespace DIE?

Reply via email to