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

--- Comment #7 from Alexey Neyman <stilor at att dot net> ---
(In reply to Richard Biener from comment #6)
> (In reply to Alexey Neyman from comment #4)
> > Or add a similar "return if debug level is terse" at the beginning of
> > `gen_type_die` - I didn't notice that in C++ it could also get called not
> > through the `add_type_attribute`:
> > 
> > ```
> > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> > index 89e52a41508..b0f6680bd61 100644
> > --- a/gcc/dwarf2out.c
> > +++ b/gcc/dwarf2out.c
> > @@ -25709,6 +25709,9 @@ gen_type_die_with_usage (tree type, dw_die_ref
> > context_die,
> >  static void
> >  gen_type_die (tree type, dw_die_ref context_die)
> >  {
> > +  if (debug_info_level <= DINFO_LEVEL_TERSE)
> > +    return;
> > +
> >    if (type != error_mark_node)
> >      {
> >        gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
> > ```
> > 
> > I verified that it makes the attached test case compile successfully.
> 
> But then the static var is improperly scoped in the debug info?  IMHO
> it's better left out.

First, which static variable? The test case for this PR does not have any
static vars:

```
class a {
  virtual void c() {}
} extern b;
a b;
```

As to DECL_FILE_SCOPE_P check, do you mean something like this?

```
@@ -26360,7 +26365,8 @@ gen_decl_die (tree decl, tree origin, struct
vlr_context *ctx,
         variable declarations or definitions unless it is external.  */
       if (debug_info_level < DINFO_LEVEL_TERSE
          || (debug_info_level == DINFO_LEVEL_TERSE
-             && !TREE_PUBLIC (decl_or_origin)))
+             && (!TREE_PUBLIC (decl_or_origin)
+                      || !DECL_FILE_SCOPE_P(decl_or_origin))))
        break;

       if (debug_info_level > DINFO_LEVEL_TERSE) {
@@ -26841,7 +26847,8 @@ dwarf2out_decl (tree decl)
         variable declarations or definitions unless it is external.  */
       if (debug_info_level < DINFO_LEVEL_TERSE
          || (debug_info_level == DINFO_LEVEL_TERSE
-             && !TREE_PUBLIC (decl)))
+             && (!TREE_PUBLIC (decl)
+                      || !DECL_FILE_SCOPE_P(decl))))
        return;
       break;

```

This change doesn't resolve the ICE with that test.

I am going to attach a patch with what I suggested. Whether it is accepted, or
something different needs to be done - I don't have commit access, so somebody
else will have to commit it.

Reply via email to