Blame SOURCES/gcc10-pr97060.patch

16de1b
2020-11-11  Jason Merrill  <jason@redhat.com>
16de1b
16de1b
	PR debug/97060
16de1b
	* dwarf2out.c (gen_subprogram_die): It's a declaration
16de1b
	if DECL_INITIAL isn't set.
16de1b
16de1b
	* gcc.dg/debug/dwarf2/pr97060.c: New test.
16de1b
16de1b
--- gcc/dwarf2out.c
16de1b
+++ gcc/dwarf2out.c
16de1b
@@ -22859,6 +22859,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
16de1b
           available.
16de1b
   */
16de1b
   int declaration = (current_function_decl != decl
16de1b
+		     || (!DECL_INITIAL (decl) && !origin)
16de1b
 		     || class_or_namespace_scope_p (context_die));
16de1b
 
16de1b
   /* A declaration that has been previously dumped needs no
16de1b
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr97060.c
16de1b
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr97060.c
16de1b
@@ -0,0 +1,13 @@
16de1b
+/* PR debug/97060 */
16de1b
+/* { dg-do compile } */
16de1b
+/* { dg-options "-g -dA" } */
16de1b
+/* { dg-final { scan-assembler-times "DW_AT_declaration" 2 } } */
16de1b
+
16de1b
+extern int foo (unsigned int, unsigned int);
16de1b
+
16de1b
+int
16de1b
+bar (void)
16de1b
+{
16de1b
+  foo (1, 2);
16de1b
+  return 0;
16de1b
+}