aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2015-06-15 16:34:53 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2015-06-15 16:34:53 +0000
commit8e6dce3de77bcb858920d02e0f4e00159658d555 (patch)
treebe9d1723f1337dc4aa9bdc5c56ce111f2bb5937a
parentfb5b53524691063bc8dd9014b5f1b05ce3d1c0aa (diff)
downloadgcc-8e6dce3de77bcb858920d02e0f4e00159658d555.zip
gcc-8e6dce3de77bcb858920d02e0f4e00159658d555.tar.gz
gcc-8e6dce3de77bcb858920d02e0f4e00159658d555.tar.bz2
re PR debug/66535 (segfault in gen_subprogram_die after debug-early merge)
PR debug/66535 * dwarf2out.c (gen_subprogram_die): Do not check a parent's tag if there is no parent. From-SVN: r224486
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dwarf2out.c3
-rw-r--r--gcc/testsuite/gnat.dg/debug4.adb10
-rw-r--r--gcc/testsuite/gnat.dg/debug4_pkg.adb23
-rw-r--r--gcc/testsuite/gnat.dg/debug4_pkg.ads28
5 files changed, 69 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f9cf115..48b9ca7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-15 Aldy Hernandez <aldyh@redhat.com>
+
+ PR debug/66535
+ * dwarf2out.c (gen_subprogram_die): Do not check a parent's tag if
+ there is no parent.
+
2015-06-14 Shiva Chen <shiva0217@gmail.com>
* aarch64.c (aarch64_simd_lane_bounds): Change %ld to %wd for
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index d2c516a..4fe33f8 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18790,7 +18790,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
end function
end module
*/
- || old_die->die_parent->die_tag == DW_TAG_module
+ || (old_die->die_parent
+ && old_die->die_parent->die_tag == DW_TAG_module)
|| context_die == NULL)
&& (DECL_ARTIFICIAL (decl)
|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
diff --git a/gcc/testsuite/gnat.dg/debug4.adb b/gcc/testsuite/gnat.dg/debug4.adb
new file mode 100644
index 0000000..1ec37c2
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug4.adb
@@ -0,0 +1,10 @@
+-- { dg-compile }
+-- { dg-options "-g" }
+
+with Debug4_Pkg;
+
+procedure Debug4 is
+ package P is new Debug4_Pkg (Natural);
+begin
+ null;
+end;
diff --git a/gcc/testsuite/gnat.dg/debug4_pkg.adb b/gcc/testsuite/gnat.dg/debug4_pkg.adb
new file mode 100644
index 0000000..18ba0c0
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug4_pkg.adb
@@ -0,0 +1,23 @@
+package body Debug4_Pkg is
+
+ type Vertex_To_Vertex_T is array (Vertex_Id range <>) of Vertex_Id;
+
+ function Dominator_Tree_Internal (G : T'Class) return Vertex_To_Vertex_T is
+ subtype V_To_V is Vertex_To_Vertex_T (0 .. G.Vertices.Last_Index);
+ type V_To_VIL is array
+ (Valid_Vertex_Id range 1 .. G.Vertices.Last_Index)
+ of Vertex_Index_List;
+ Bucket : V_To_VIL := (others => VIL.Empty_Vector);
+ Dom : V_To_V := (others => 0);
+ begin
+ return Dom;
+ end;
+
+ function Dominator_Tree (G : T'Class) return T is
+ Dom : constant Vertex_To_Vertex_T := Dominator_Tree_Internal (G);
+ DT : T := (Vertices => VL.Empty_Vector);
+ begin
+ return DT;
+ end;
+
+end Debug4_Pkg;
diff --git a/gcc/testsuite/gnat.dg/debug4_pkg.ads b/gcc/testsuite/gnat.dg/debug4_pkg.ads
new file mode 100644
index 0000000..bac4953
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug4_pkg.ads
@@ -0,0 +1,28 @@
+with Ada.Containers.Vectors;
+
+generic
+ type Vertex_Key is private;
+package Debug4_Pkg is
+
+ type Vertex_Id is new Natural;
+ subtype Valid_Vertex_Id is Vertex_Id range 1 .. Vertex_Id'Last;
+
+ package VIL is new Ada.Containers.Vectors
+ (Index_Type => Positive,
+ Element_Type => Valid_Vertex_Id);
+ use VIL;
+ subtype Vertex_Index_List is VIL.Vector;
+
+ package VL is new Ada.Containers.Vectors
+ (Index_Type => Valid_Vertex_Id,
+ Element_Type => Vertex_Key);
+ use VL;
+ subtype Vertex_List is VL.Vector;
+
+ type T is tagged record
+ Vertices : Vertex_List;
+ end record;
+
+ function Dominator_Tree (G : T'Class) return T;
+
+end Debug4_Pkg;