re PR c++/82054 (ICE in add_dwarf_attr with -fopenmp and -g)
authorRichard Biener <rguenther@suse.de>
Thu, 31 Aug 2017 11:20:54 +0000 (11:20 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 31 Aug 2017 11:20:54 +0000 (11:20 +0000)
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.

From-SVN: r251559

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr82054.C [new file with mode: 0644]

index 239c93390632a723abedbd39719224592608ce62..175759c54aad260cf98a5e962c7f0cc5ec15125e 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-31  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/82054
+       * dwarf2out.c (dwarf2out_early_global_decl): Process each
+       function only once.
+
 2017-08-31  Tamar Christina  <tamar.christina@arm.com>
 
        * config/aarch64/aarch64-builtins.c (aarch64_init_simd_builtins):
index 42da36ca62e96dd01f6785074639d542eae72691..651dd0c78729bee119f85a85484249f8b50745b3 100644 (file)
@@ -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 98b269e3dbfa44e8241b4da9842630f90017fa26..ff5169ae1f7d33d1ad7099c05c4a528642d8b69e 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-31  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/82054
+       * g++.dg/gomp/pr82054.C: New testcase.
+
 2017-08-31  Renlin Li  <renlin.li@arm.com>
            Aaron Sawdey  <acsawdey@linux.vnet.ibm.com>
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr82054.C b/gcc/testsuite/g++.dg/gomp/pr82054.C
new file mode 100644 (file)
index 0000000..3c6aa27
--- /dev/null
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-additional-options "-g" }
+
+class a
+{
+  bool b ();
+};
+bool
+a::b ()
+{
+#pragma omp parallel
+  ;
+}