Hello,

Under specific circumstances for Ada programs, such as in the testcase
this change adds, the DWARF back-end currently crashes because of
inconsistent internal state. This is due to a typo: a local variable is
called frame_offset_ but resolve_args_picking_1 wrongly modifies
emit-rtl.h's frame_offset instead.

This change fixes this typo. Bootstrapped and regtested on x86_64-linux
successfuly. Ok to commit? Thank you in advance!

gcc/
        * dwarf2out.c (resolve_args_picking_1): Replace the frame_offset
        occurence with frame_offset_ ones.

gcc/testsuite/
        * gnat.dg/debug5.adb: New testcase.
---
 gcc/dwarf2out.c                  |  2 +-
 gcc/testsuite/gnat.dg/debug5.adb | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gnat.dg/debug5.adb

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 463863d..ab851f4 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -15571,7 +15571,7 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned 
initial_frame_offset,
 
            if (stack_usage == NULL)
              return false;
-           frame_offset += *stack_usage;
+           frame_offset_ += *stack_usage;
            break;
          }
 
diff --git a/gcc/testsuite/gnat.dg/debug5.adb b/gcc/testsuite/gnat.dg/debug5.adb
new file mode 100644
index 0000000..6569a15
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug5.adb
@@ -0,0 +1,22 @@
+-- { dg-do compile }
+-- { dg-options "-g" }
+
+procedure Debug5 is
+
+   type Record_Type (L1, L2 : Natural) is record
+      S1 : String (1 .. L1);
+      case L2 is
+         when 0      => null;
+         when others => S2 : String (L1 .. L2);
+      end case;
+   end record;
+
+   procedure Discard (R : Record_Type) is
+   begin
+      null;
+   end Discard;
+
+   R : constant Record_Type := (0, 0, others => <>);
+begin
+   Discard (R);
+end Debug5;
-- 
2.7.4

Reply via email to