aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-07-03 08:14:15 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-03 08:14:15 +0000
commit09c9ed5bb8b8e3b65dd2f631bf18f6b796499fbd (patch)
treea0f13786145129994116d8620769483ced1276dc /gcc/ada
parent6cbd53c2277e5013d83fe73d5e73844066b651a7 (diff)
downloadgcc-09c9ed5bb8b8e3b65dd2f631bf18f6b796499fbd.zip
gcc-09c9ed5bb8b8e3b65dd2f631bf18f6b796499fbd.tar.gz
gcc-09c9ed5bb8b8e3b65dd2f631bf18f6b796499fbd.tar.bz2
[Ada] Fix bogus error on array with overaligned scalar component
The compiler would wrongly reject an alignment clause larger than 8 on the component type of an array of scalars, which is valid albeit pathological. 2019-07-03 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * layout.adb (Layout_Type): Do not set the component size of an array with a scalar component if the component type is overaligned. gcc/testsuite/ * gnat.dg/alignment14.adb: New testcase. From-SVN: r272968
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/layout.adb10
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 443947c..e932dab65 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * layout.adb (Layout_Type): Do not set the component size of an
+ array with a scalar component if the component type is
+ overaligned.
+
2019-07-03 Ed Schonberg <schonberg@adacore.com>
* inline.adb (Make_Loop_Labels_Unique): New procedure to modify
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index f5f6aa8..5637946 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -443,9 +443,12 @@ package body Layout is
Set_RM_Size (E, Esize (E));
end if;
- -- For array base types, set component size if object size of the
+ -- For array base types, set the component size if object size of the
-- component type is known and is a small power of 2 (8, 16, 32, 64),
- -- since this is what will always be used.
+ -- since this is what will always be used, except if a very large
+ -- alignment was specified and so Adjust_Esize_For_Alignment gave up
+ -- because, in this case, the object size is not a multiple of the
+ -- alignment and, therefore, cannot be the component size.
if Ekind (E) = E_Array_Type and then Unknown_Component_Size (E) then
declare
@@ -458,6 +461,9 @@ package body Layout is
if Present (CT)
and then Is_Scalar_Type (CT)
and then Known_Static_Esize (CT)
+ and then not (Known_Alignment (CT)
+ and then Alignment_In_Bits (CT) >
+ Standard_Long_Long_Integer_Size)
then
declare
S : constant Uint := Esize (CT);