public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-3698] ada: Fix DWARF for certain arrays
Date: Tue,  5 Sep 2023 11:09:27 +0000 (GMT)	[thread overview]
Message-ID: <20230905110927.715663883013@sourceware.org> (raw)

https://gcc.gnu.org/g:7f77d69bc86d25262b88503d0f5e3fff11c7898e

commit r14-3698-g7f77d69bc86d25262b88503d0f5e3fff11c7898e
Author: Tom Tromey <tromey@adacore.com>
Date:   Mon Aug 21 17:11:13 2023 +0000

    ada: Fix DWARF for certain arrays
    
    An array whose index type is a nonstandard enum will be marked as
    "packed", but should not emit DW_AT_bit_stride unless it is also
    bit-packed.
    
    gcc/ada/
    
            * gcc-interface/decl.cc (gnat_to_gnu_entity): Set bit-packed for
            constrained and unconstrained array types.
            * gcc-interface/misc.cc (gnat_get_array_descr_info): Examine
            BIT_PACKED_ARRAY_TYPE_P.

Diff:
---
 gcc/ada/gcc-interface/decl.cc |  8 +++++++-
 gcc/ada/gcc-interface/misc.cc | 14 +++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index ae756b35fdb3..0cf7d3cee600 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2388,6 +2388,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	  = (Is_Packed (gnat_entity)
 	     || Is_Packed_Array_Impl_Type (gnat_entity));
 
+	TYPE_BIT_PACKED_ARRAY_TYPE_P (tem)
+	  = (Is_Packed_Array_Impl_Type (gnat_entity)
+	     ? Is_Bit_Packed_Array (Original_Array_Type (gnat_entity))
+	     : Is_Bit_Packed_Array (gnat_entity));
+
 	if (Treat_As_Volatile (gnat_entity))
 	  tem = change_qualified_type (tem, TYPE_QUAL_VOLATILE);
 
@@ -2815,7 +2820,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 
 	  TYPE_BIT_PACKED_ARRAY_TYPE_P (gnu_type)
 	    = (Is_Packed_Array_Impl_Type (gnat_entity)
-	       && Is_Bit_Packed_Array (Original_Array_Type (gnat_entity)));
+	       ? Is_Bit_Packed_Array (Original_Array_Type (gnat_entity))
+	       : Is_Bit_Packed_Array (gnat_entity));
 
 	  /* If the maximum size doesn't overflow, use it.  */
 	  if (gnu_max_size
diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc
index 30319ae58b1b..3b21bf5b43aa 100644
--- a/gcc/ada/gcc-interface/misc.cc
+++ b/gcc/ada/gcc-interface/misc.cc
@@ -774,7 +774,7 @@ gnat_get_array_descr_info (const_tree const_type,
 {
   tree type = const_cast<tree> (const_type);
   tree first_dimen, dimen;
-  bool is_packed_array, is_array;
+  bool is_bit_packed_array, is_array;
   int i;
 
   /* Temporaries created in the first pass and used in the second one for thin
@@ -784,15 +784,15 @@ gnat_get_array_descr_info (const_tree const_type,
   tree thinptr_template_expr = NULL_TREE;
   tree thinptr_bound_field = NULL_TREE;
 
-  /* If we have an implementation type for a packed array, get the orignial
+  /* If we have an implementation type for a packed array, get the original
      array type.  */
   if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type))
     {
+      is_bit_packed_array = BIT_PACKED_ARRAY_TYPE_P (type);
       type = TYPE_ORIGINAL_PACKED_ARRAY (type);
-      is_packed_array = true;
     }
   else
-    is_packed_array = false;
+    is_bit_packed_array = false;
 
   /* First pass: gather all information about this array except everything
      related to dimensions.  */
@@ -850,8 +850,8 @@ gnat_get_array_descr_info (const_tree const_type,
      order, so our view here has reversed dimensions.  */
   const bool convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen);
 
-  if (TYPE_PACKED (first_dimen))
-    is_packed_array = true;
+  if (BIT_PACKED_ARRAY_TYPE_P (first_dimen))
+    is_bit_packed_array = true;
 
   /* ??? For row major ordering, we probably want to emit nothing and
      instead specify it as the default in Dw_TAG_compile_unit.  */
@@ -975,7 +975,7 @@ gnat_get_array_descr_info (const_tree const_type,
       /* We need to specify a bit stride when it does not correspond to the
 	 natural size of the contained elements.  ??? Note that we do not
 	 support packed records and nested packed arrays.  */
-      else if (is_packed_array)
+      else if (is_bit_packed_array)
 	{
 	  info->stride = get_array_bit_stride (info->element_type);
 	  info->stride_in_bits = true;

                 reply	other threads:[~2023-09-05 11:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230905110927.715663883013@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).