https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97599
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another version of the patch:
--- gcc/dwarf2out.c.jj 2020-10-27 18:38:00.001979404 +0100
+++ gcc/dwarf2out.c 2020-10-28 10:52:29.618796758 +0100
@@ -22756,6 +22756,7 @@ gen_subprogram_die (tree decl, dw_die_re
tree origin = decl_ultimate_origin (decl);
dw_die_ref subr_die;
dw_die_ref old_die = lookup_decl_die (decl);
+ bool old_die_had_no_children = false;
/* This function gets called multiple times for different stages of
the debug process. For example, for func() in this code:
@@ -22846,6 +22847,9 @@ gen_subprogram_die (tree decl, dw_die_re
if (old_die && declaration)
return;
+ if (in_lto_p && old_die && old_die->die_child == NULL)
+ old_die_had_no_children = true;
+
/* Now that the C++ front end lazily declares artificial member fns, we
might need to retrofit the declaration into its class. */
if (!declaration && !origin && !old_die
@@ -23365,6 +23369,10 @@ gen_subprogram_die (tree decl, dw_die_re
else if (DECL_INITIAL (decl) == NULL_TREE)
gen_unspecified_parameters_die (decl, subr_die);
}
+ else if ((subr_die != old_die || old_die_had_no_children)
+ && prototype_p (TREE_TYPE (decl))
+ && stdarg_p (TREE_TYPE (decl)))
+ gen_unspecified_parameters_die (decl, subr_die);
}
if (subr_die != old_die)