aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-04-29 11:39:24 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2021-07-05 13:09:14 +0000
commit1d1e91f4c3f74bfa4d106d184ca206b5abccec4f (patch)
tree27e0659d556f8e11a85a73a3ae12a4fef88485f9
parent63b43535dc775883436ac5c8445522e34e373efc (diff)
downloadgcc-1d1e91f4c3f74bfa4d106d184ca206b5abccec4f.zip
gcc-1d1e91f4c3f74bfa4d106d184ca206b5abccec4f.tar.gz
gcc-1d1e91f4c3f74bfa4d106d184ca206b5abccec4f.tar.bz2
[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.
-rw-r--r--gcc/ada/sem_util.adb9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index e0a12bd..25060cc 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.