From 8857ae1c20b1a7efa789d7f95674043b3e49ac51 Mon Sep 17 00:00:00 2001
From: Alexandre Oliva <aoliva@redhat.com>
Date: Fri, 16 Mar 2007 05:08:25 +0000
Subject: [PATCH] re PR debug/29906 (-g option creates internal compiler error)

gcc/ChangeLog:
PR debug/29906
* dwarf2out.c (force_type_die): Adjust comment.
(dwarf2out_imported_module_or_decl): Handle base AT_import types.
gcc/testsuite/ChangeLog:
PR debug/29906
* g++.dg/debug/pr29906.C: New

From-SVN: r122976
---
 gcc/ChangeLog                        |  6 ++++++
 gcc/dwarf2out.c                      | 10 ++++++++--
 gcc/testsuite/ChangeLog              |  5 +++++
 gcc/testsuite/g++.dg/debug/pr29906.C | 10 ++++++++++
 4 files changed, 29 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/pr29906.C

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6b1c432b7510..c1aa2e0943e7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-16  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.
+
 2007-03-15  DJ Delorie  <dj@redhat.com>
 
 	* config/frv/predicates.md (minmax_operator): Don't check operands
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 476f6ebf794c..fa00452e594e 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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 decl, tree context)
 
   /* 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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 63e7ef5daa7c..395028ac3e88 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-16  Alexandre Oliva  <aoliva@redhat.com>
+
+	PR debug/29906
+	* g++.dg/debug/pr29906.C: New
+
 2007-03-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
 	PR libgfortran/31099
diff --git a/gcc/testsuite/g++.dg/debug/pr29906.C b/gcc/testsuite/g++.dg/debug/pr29906.C
new file mode 100644
index 000000000000..08bbe879bed5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr29906.C
@@ -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;
+};
-- 
GitLab