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]

[PATCH] Fix segfault in rtl_for_decl_location


Hi!

The attached testcase causes segfault in rtl_for_decl_location
on x86_64-redhat-linux with -O{2,3} -g.
The bug was introduced by the PR debug/15860 patch, before that
DECL_INCOMING_RTL just caused rtl to not be set (i.e. left
NULL or is_pseudo_reg ()) and later code dealt with that.

The following patch fixes that, ok to commit to HEAD/3.4?

2004-10-23  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (rtl_for_decl_location): Avoid segfault if
	DECL_INCOMING_RTL is NULL.

	* gcc.dg/debug/20041023-1.c: New test.

--- gcc/dwarf2out.c.jj	2004-10-18 14:33:33.000000000 +0200
+++ gcc/dwarf2out.c	2004-10-23 23:46:17.810003735 +0200
@@ -9480,7 +9480,8 @@ rtl_for_decl_location (tree decl)
 	  if (dmode == pmode)
 	    rtl = DECL_INCOMING_RTL (decl);
 	  else if (SCALAR_INT_MODE_P (dmode)
-		   && GET_MODE_SIZE (dmode) <= GET_MODE_SIZE (pmode))
+		   && GET_MODE_SIZE (dmode) <= GET_MODE_SIZE (pmode)
+		   && DECL_INCOMING_RTL (decl))
 	    {
 	      rtx inc = DECL_INCOMING_RTL (decl);
 	      if (REG_P (inc))
--- gcc/testsuite/gcc.dg/debug/20041023-1.c.jj	2004-10-23 23:48:23.154745859 +0200
+++ gcc/testsuite/gcc.dg/debug/20041023-1.c	2004-10-23 22:24:45.000000000 +0200
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+static void
+foo (unsigned char x)
+{
+  unsigned char a[5 + x];
+}
+
+void
+bar (void)
+{
+  foo (80);
+}

	Jakub


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