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 r12-2026] [Ada] Fix excessive check for alignment of overlaying objects
Date: Mon,  5 Jul 2021 13:14:59 +0000 (GMT)	[thread overview]
Message-ID: <20210705131459.A0E98384002C@sourceware.org> (raw)

https://gcc.gnu.org/g:1d1e91f4c3f74bfa4d106d184ca206b5abccec4f

commit r12-2026-g1d1e91f4c3f74bfa4d106d184ca206b5abccec4f
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Thu Apr 29 11:39:24 2021 +0200

    [Ada] Fix excessive check for alignment of overlaying objects
    
    gcc/ada/
    
            * sem_util.adb (Has_Compatible_Alignment_Internal): If the
            prefix of the Address expression is an entire object with a
            known alignment, then skip checks related to its size.

Diff:
---
 gcc/ada/sem_util.adb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index e0a12bddca1..25060cc9502 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -11939,6 +11939,7 @@ package body Sem_Util is
                   elsif Is_Entity_Name (Expr)
                     and then Known_Alignment (Entity (Expr))
                   then
+                     Offs := Uint_0;
                      ExpA := Alignment (Entity (Expr));
 
                   --  Otherwise, we can use the alignment of the type of Expr
@@ -11961,9 +11962,9 @@ package body Sem_Util is
                      Set_Result (Known_Incompatible);
                   end if;
 
-                  --  If Expr is not a piece of a larger object, see if size
-                  --  is given. If so, check that it is not too small for the
-                  --  required alignment.
+                  --  If Expr is a component or an entire object with a known
+                  --  alignment, then we are fine. Otherwise, if its size is
+                  --  known, it must be big enough for the required alignment.
 
                   if Offs /= No_Uint then
                      null;
@@ -11982,7 +11983,7 @@ package body Sem_Util is
                   end if;
 
                   --  If we got a size, see if it is a multiple of the Obj
-                  --  alignment, if not, then the alignment cannot be
+                  --  alignment; if not, then the alignment cannot be
                   --  acceptable, since the size is always a multiple of the
                   --  alignment.


                 reply	other threads:[~2021-07-05 13:14 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=20210705131459.A0E98384002C@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).