dwarf2out.c (rtl_for_decl_location): Avoid segfault if DECL_INCOMING_RTL is NULL.
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Oct 2004 21:43:11 +0000 (23:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Oct 2004 21:43:11 +0000 (23:43 +0200)
* dwarf2out.c (rtl_for_decl_location): Avoid segfault if
DECL_INCOMING_RTL is NULL.

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

From-SVN: r89554

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/20041023-1.c [new file with mode: 0644]

index bcdfb1ab05b0e6fe994ef164a2c1838d188a783f..e8bdb1f97ffa0ef46be6912b5825e3ae9666c043 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * dwarf2out.c (rtl_for_decl_location): Avoid segfault if
+       DECL_INCOMING_RTL is NULL.
+
 2004-10-25  Steven Bosscher  <stevenb@suse.de>
 
        * timevar.def (TV_FIND_REFERENCED_VARS): New.
index f4c5974109115f671d744338fb8529b54a129432..a6b923c3f40af6493f306942eec58990b5182b79 100644 (file)
@@ -9807,7 +9807,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))
index 765daa2758f79c075e90e43f0c0411930e3582a4..19c32bb3d3ccfcbb652f5463348d158485d1bd0a 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/debug/20041023-1.c: New test.
+
 2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR middle-end/17407
diff --git a/gcc/testsuite/gcc.dg/debug/20041023-1.c b/gcc/testsuite/gcc.dg/debug/20041023-1.c
new file mode 100644 (file)
index 0000000..12b7cb9
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+static void
+foo (unsigned char x)
+{
+  unsigned char a[5 + x];
+}
+
+void
+bar (void)
+{
+  foo (80);
+}