diff mbox

[dwarf] : PR/47209 Segfault in should_emit_struct_debug

Message ID AANLkTiknUvqiXXEN0_8vF3mq6XRWybkN7C0SQXyRa+eu@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Jan. 11, 2011, 9:36 p.m. UTC
2011/1/11 H.J. Lu <hjl.tools@gmail.com>:
> On Tue, Jan 11, 2011 at 12:58 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> Hello,
>>
>> following patch fixes reported segfault at
>>
>> ChangeLog
>>
>> 2011-01-11  Kai Tietz
>>
>>          PR debug/47209
>>          * dwarfout2.c (should_emit_struct_debug): Use TYPE_MAIN_VARIANT
>>          of type.
>>
>> Tested for x86_64-pc-linux-gnu and x86_64-pc-mingw32. Ok for apply?
>>
>
> You need to add testcases.
>
>
> --
> H.J.
>

Yes, missed that.

ChangeLog for testsuite

          PR debug/47209
          * /g++.dg/debug/pr47209.C: New.

Regards,
Kai
diff mbox

Patch

Index: gcc/gcc/dwarf2out.c
===================================================================
--- gcc.orig/gcc/dwarf2out.c	2011-01-11 22:26:26.000000000 +0100
+++ gcc/gcc/dwarf2out.c	2011-01-11 21:57:09.704996700 +0100
@@ -619,7 +619,7 @@ 
   if (criterion == DINFO_STRUCT_FILE_ANY)
     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
 
-  type_decl = TYPE_STUB_DECL (type);
+  type_decl = TYPE_STUB_DECL(TYPE_MAIN_VARIANT(type));
 
   if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
Index: gcc/gcc/testsuite/g++.dg/debug/pr47209.C
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/gcc/testsuite/g++.dg/debug/pr47209.C	2011-01-11 22:30:44.711248500 +0100
@@ -0,0 +1,12 @@ 
+// { dg-do compile }
+// { dg-options "-femit-struct-debug-baseonly -g" }
+struct A
+{
+  void foo ();
+};
+
+struct B : A
+{
+  typedef const A base;
+  using base::foo;
+};