diff mbox

Fix PR debug/47361

Message ID m3ipxel2m5.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli Jan. 24, 2011, 3:53 p.m. UTC
Dodji Seketeli <dodji@redhat.com> writes:

> Jason Merrill <jason@redhat.com> writes:
>
>> This change is OK, but I don't think we want decltype(nullptr) to go
>> into a comdat CU, so let's test for it in is_comdat_die as well.
>
> Yes. I have therefore tested the patch below on x86_64-unknown-linux-gnu
> against trunk.

Jakub pointed out on IRC that I should test this with -gdwarf4 as well
since that flag makes the compiler take another path to eliminate type
DIE dups. So I have added a test with that flag.

Tested likewise.
diff mbox

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2309297..44a3768 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -9618,6 +9618,7 @@  is_type_die (dw_die_ref die)
     case DW_TAG_packed_type:
     case DW_TAG_volatile_type:
     case DW_TAG_typedef:
+    case DW_TAG_unspecified_type:
       return 1;
     default:
       return 0;
@@ -9635,9 +9636,11 @@  is_comdat_die (dw_die_ref c)
   /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as
      we do for stabs.  The advantage is a greater likelihood of sharing between
      objects that don't include headers in the same order (and therefore would
-     put the base types in a different comdat).  jason 8/28/00 */
+     put the base types in a different comdat).  jason 8/28/00
+     We don't put DW_TAG_unspecified_type in comdat sections either.  */
 
-  if (c->die_tag == DW_TAG_base_type)
+  if (c->die_tag == DW_TAG_base_type
+      || c->die_tag == DW_TAG_unspecified_type)
     return 0;
 
   if (c->die_tag == DW_TAG_pointer_type
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C
new file mode 100644
index 0000000..54f597e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-1.C
@@ -0,0 +1,11 @@ 
+// Origin PR debug/47361
+// { dg-options "-g -std=gnu++0x -feliminate-dwarf2-dups" }
+
+typedef decltype (nullptr) nullptr_t;
+
+struct A
+{
+  A (nullptr_t = 0);
+};
+
+A a;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C
new file mode 100644
index 0000000..f6d656c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nullptr-2.C
@@ -0,0 +1,11 @@ 
+// Origin PR debug/47361
+// { dg-options "-g -std=gnu++0x -feliminate-dwarf2-dups -gdwarf-4" }
+
+typedef decltype (nullptr) nullptr_t;
+
+struct A
+{
+  A (nullptr_t = 0);
+};
+
+A a;