public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-529] [Ada] Deal with derived record types in Has_Compatible_Representation
Date: Tue, 17 May 2022 08:28:08 +0000 (GMT)	[thread overview]
Message-ID: <20220517082808.486C13857831@sourceware.org> (raw)

https://gcc.gnu.org/g:d678717ab233610588ae15fcddeb20b39ac7daf5

commit r13-529-gd678717ab233610588ae15fcddeb20b39ac7daf5
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Mar 21 08:35:53 2022 +0100

    [Ada] Deal with derived record types in Has_Compatible_Representation
    
    More precisely, untagged record types, as tagged record types are already
    handled by the predicate.  If the derived type has not been given its own
    representation clause, then the representations are the same.
    
    gcc/ada/
    
            * sem_ch13.adb (Has_Compatible_Representation): Return true for
            derived untagged record types without representation clause.

Diff:
---
 gcc/ada/sem_ch13.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 93f5e452bd4..ac94de7e84a 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -13539,6 +13539,16 @@ package body Sem_Ch13 is
          if Is_Packed (T1) /= Is_Packed (T2) then
             return False;
 
+         --  If the operand type is derived from the target type and no clause
+         --  has been given after the derivation, then the representations are
+         --  the same since the derived type inherits that of the parent type.
+
+         elsif Is_Derived_Type (T2)
+           and then Etype (T2) = T1
+           and then not Has_Record_Rep_Clause (T2)
+         then
+            return True;
+
          --  Otherwise we must check components. Typ2 maybe a constrained
          --  subtype with fewer components, so we compare the components
          --  of the base types.


                 reply	other threads:[~2022-05-17  8:28 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=20220517082808.486C13857831@sourceware.org \
    --to=pmderodat@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).