https://gcc.gnu.org/g:4f96af24fbfa3b7d6d43149c01e7d9a0a5b3e248

commit 4f96af24fbfa3b7d6d43149c01e7d9a0a5b3e248
Author: Alexandre Oliva <ol...@adacore.com>
Date:   Tue Jun 11 20:30:30 2024 -0300

    map packed field type to unpacked for debug info
    
    We create a distinct type for each field in a packed record with a
    gnu_size, but there is no distinct debug information for them.  Use
    the same unpacked type for debug information.
    
    
    for  gcc/ada/ChangeLog
    
            * gcc-interface/decl.cc (gnat_to_gnu_field): Use unpacked type
            as the debug type for packed fields.
    
    for  gcc/testsuite/ChangeLog
    
            * gnat.dg/bias1.adb: Count occurrences of -7.*DW_AT_GNU_bias.

Diff:
---
 gcc/ada/gcc-interface/decl.cc   | 4 ++++
 gcc/testsuite/gnat.dg/bias1.adb | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 8b72c96c4396..e97ff64a4805 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -7786,6 +7786,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree 
gnu_record_type, int packed,
   /* If a size is specified, adjust the field's type to it.  */
   if (gnu_size)
     {
+      tree debug_field_type = gnu_field_type;
       tree orig_field_type;
 
       /* If the field's type is justified modular, we would need to remove
@@ -7844,6 +7845,9 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree 
gnu_record_type, int packed,
          && !DECL_P (TYPE_NAME (gnu_field_type)))
        create_type_decl (TYPE_NAME (gnu_field_type), gnu_field_type, true,
                          debug_info_p, gnat_field);
+
+      if (debug_info_p && gnu_field_type != debug_field_type)
+       SET_TYPE_DEBUG_TYPE (gnu_field_type, debug_field_type);
     }
 
   /* Otherwise (or if there was an error), don't specify a position.  */
diff --git a/gcc/testsuite/gnat.dg/bias1.adb b/gcc/testsuite/gnat.dg/bias1.adb
index 016a159b692d..d9a00a1aa458 100644
--- a/gcc/testsuite/gnat.dg/bias1.adb
+++ b/gcc/testsuite/gnat.dg/bias1.adb
@@ -1,6 +1,7 @@
 --  { dg-do compile }
 --  { dg-options "-cargs -g -dA -gnatws -fgnat-encodings=gdb -margs" }
 --  { dg-final { scan-assembler "DW_AT_GNU_bias" } }
+--  { dg-final { scan-assembler-times "-7.*DW_AT_GNU_bias" 1 } }
 
 procedure Bias1 is
    type Small is range -7 .. -4;
@@ -31,4 +32,4 @@ procedure Bias1 is
 
 begin
    null;
-end Bias1;
\ No newline at end of file
+end Bias1;

Reply via email to