This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PR29906] Handle DW_AT_import <base type>


We used to ICE with the testcase in the patch below because
force_type_die would not create dies for base types.

In most cases, it doesn't have to, since it's used for contexts of
other types or declarations, and these are never base types (right?)

But in the one case adjusted by the patch below, namely using
declarations that create aliases for types, it can be a base type.

Instead of burdening all uses with an additional unneeded test in
force_type_die itself, I figured it made more sense to handle this
special need in the only (provided that my assumption above holds)
location where this case makes sense.

Bootstrapping and regtesting on x86_64-linux-gnu, but this looks
obvious enough to me that I thought I'd go ahead and post it.

Ok to install?

:ADDPATCH debug:

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/29906
	* dwarf2out.c (force_type_die): Adjust comment.
	(dwarf2out_imported_module_or_decl): Handle base AT_import types.

for  gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/29906
	* g++.dg/debug/pr29906.C: New

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c.orig	2007-03-08 07:25:36.000000000 -0300
+++ gcc/dwarf2out.c	2007-03-13 05:26:57.000000000 -0300
@@ -13160,7 +13160,8 @@ force_decl_die (tree decl)
   return decl_die;
 }
 
-/* Returns the DIE for TYPE.  A DIE is always returned.  */
+/* Returns the DIE for TYPE, that must not be a base type.  A DIE is
+   always returned.  */
 
 static dw_die_ref
 force_type_die (tree type)
@@ -13488,7 +13489,12 @@ dwarf2out_imported_module_or_decl (tree 
 
   /* For TYPE_DECL or CONST_DECL, lookup TREE_TYPE.  */
   if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL)
-    at_import_die = force_type_die (TREE_TYPE (decl));
+    {
+      if (is_base_type (TREE_TYPE (decl)))
+	at_import_die = base_type_die (TREE_TYPE (decl));
+      else
+	at_import_die = force_type_die (TREE_TYPE (decl));
+    }
   else
     {
       at_import_die = lookup_decl_die (decl);
Index: gcc/testsuite/g++.dg/debug/pr29906.C
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/g++.dg/debug/pr29906.C	2007-03-13 05:28:24.000000000 -0300
@@ -0,0 +1,10 @@
+// { dg-do compile }
+// { dg-options "-g -fno-emit-class-debug-always" }
+
+struct A{
+  typedef int T;
+  virtual ~A();
+};
+struct B:public A{
+  using A::T;
+};
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]