This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR82054
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 Aug 2017 12:15:54 +0200 (CEST)
- Subject: [PATCH] Fix PR82054
- Authentication-results: sourceware.org; auth=none
I am testing the following patch to fix another fallout of the
assert that we dont' add duplicated dwarf attributes.
LTO bootstrapped / bootstrapped on x86_64-unknown-linux-gnu, testing
in progress.
Richard.
2017-08-31 Richard Biener <rguenther@suse.de>
PR middle-end/82054
* dwarf2out.c (dwarf2out_early_global_decl): Process each
function only once.
* g++.dg/gomp/pr82054.C: New testcase.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 251553)
+++ gcc/dwarf2out.c (working copy)
@@ -25492,9 +25492,10 @@ dwarf2out_early_global_decl (tree decl)
if (TREE_CODE (decl) != TYPE_DECL
&& TREE_CODE (decl) != PARM_DECL)
{
- tree save_fndecl = current_function_decl;
if (TREE_CODE (decl) == FUNCTION_DECL)
{
+ tree save_fndecl = current_function_decl;
+
/* For nested functions, make sure we have DIEs for the parents first
so that all nested DIEs are generated at the proper scope in the
first shot. */
@@ -25521,11 +25522,19 @@ dwarf2out_early_global_decl (tree decl)
dwarf2out_decl (origin);
}
- current_function_decl = decl;
+ /* Emit the DIE for decl but avoid doing that multiple times. */
+ dw_die_ref old_die;
+ if ((old_die = lookup_decl_die (decl)) == NULL
+ || is_declaration_die (old_die))
+ {
+ current_function_decl = decl;
+ dwarf2out_decl (decl);
+ }
+
+ current_function_decl = save_fndecl;
}
- dwarf2out_decl (decl);
- if (TREE_CODE (decl) == FUNCTION_DECL)
- current_function_decl = save_fndecl;
+ else
+ dwarf2out_decl (decl);
}
symtab->global_info_ready = save;
}
Index: gcc/testsuite/g++.dg/gomp/pr82054.C
===================================================================
--- gcc/testsuite/g++.dg/gomp/pr82054.C (revision 0)
+++ gcc/testsuite/g++.dg/gomp/pr82054.C (working copy)
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-additional-options "-g" }
+
+class a
+{
+ bool b ();
+};
+bool
+a::b ()
+{
+#pragma omp parallel
+ ;
+}