Blame SOURCES/gcc10-pr97060.patch

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