On Wed, Nov 25, 2020 at 10:24:23AM +0100, Christophe Lyon via Gcc-patches wrote: > On Thu, 12 Nov 2020 at 06:56, Jason Merrill via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > If DECL_INITIAL isn't set, we can't emit anything about the body of the > > function, so add the declaration attribute. > > > > Tested x86_64-pc-linux-gnu, applying to trunk. > > > > gcc/ChangeLog: > > > > PR debug/97060 > > * dwarf2out.c (gen_subprogram_die): It's a declaration > > if DECL_INITIAL isn't set. > > > > gcc/testsuite/ChangeLog: > > > > PR debug/97060 > > * gcc.dg/debug/dwarf2/pr97060.c: New test. > > The new test fails on arm / aarch64, at least on the gcc-10 branch. > Can you check?
I guess that is because gcc 10 branch does not have Richard's PR96383 r11-2455-gc6ef9d8d3f11221df1ea6358b8d4e79e42f074fb changes, only trunk has that and the Fedora/RHEL gcc 10 rpms have that change applied as a patch in the spec file. So the PR97060 fix is needed only on the trunk and in the Fedora/RHEL gcc 10 rpms. Probably it won't hurt in GCC 10 if the testcase doesn't expect the DW_AT_declaration. > > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c > > index bc32a17efcd..a5aaa6c34da 100644 > > --- a/gcc/dwarf2out.c > > +++ b/gcc/dwarf2out.c > > @@ -22849,6 +22849,7 @@ gen_subprogram_die (tree decl, dw_die_ref > > context_die) > > available. > > */ > > int declaration = (current_function_decl != decl > > + || (!DECL_INITIAL (decl) && !origin) > > || class_or_namespace_scope_p (context_die)); > > > > /* A declaration that has been previously dumped needs no > > diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr97060.c > > b/gcc/testsuite/gcc.dg/debug/dwarf2/pr97060.c > > new file mode 100644 > > index 00000000000..c07b9046d9a > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr97060.c > > @@ -0,0 +1,13 @@ > > +/* PR debug/97060 */ > > +/* { dg-do compile } */ > > +/* { dg-options "-g -dA" } */ > > +/* { dg-final { scan-assembler-times "DW_AT_declaration" 2 } } */ > > + > > +extern int foo (unsigned int, unsigned int); > > + > > +int > > +bar (void) > > +{ > > + foo (1, 2); > > + return 0; > > +} > > > > base-commit: 7a9a5d1a61c7b8111557261a8d275a531812b50e > > -- > > 2.18.4 > > Jakub