aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-12-18 07:14:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-12-18 07:14:23 +0000
commit3a4425fd9a818300be9f87abd13f483c5aef9e54 (patch)
treecb72eae16db99401628f9c28f8e8b851e9a39c83 /gcc/ada
parentc846eedd56a5ecf28233d5e8fe938d44b3add5f3 (diff)
downloadgcc-3a4425fd9a818300be9f87abd13f483c5aef9e54.zip
gcc-3a4425fd9a818300be9f87abd13f483c5aef9e54.tar.gz
gcc-3a4425fd9a818300be9f87abd13f483c5aef9e54.tar.bz2
[Ada] Do not propagate Object_Size onto Size for composite types
2019-12-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * layout.adb (Layout_Type): In the case of composite types, do not copy the Esize onto the RM_Size if the latter is not set. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Also cap the alignment if an Object_Size clause has been specified. Pass VAR_DECL in the call to validate_size for the Esize of a type. (validate_size): Be prepared to give an error on an Object_Size clause. From-SVN: r279507
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/gcc-interface/decl.c25
-rw-r--r--gcc/ada/layout.adb8
3 files changed, 31 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 2b845d4..ce39bc8 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,16 @@
2019-12-18 Eric Botcazou <ebotcazou@adacore.com>
+ * layout.adb (Layout_Type): In the case of composite types, do
+ not copy the Esize onto the RM_Size if the latter is not set.
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>:
+ Also cap the alignment if an Object_Size clause has been
+ specified. Pass VAR_DECL in the call to validate_size for the
+ Esize of a type.
+ (validate_size): Be prepared to give an error on an Object_Size
+ clause.
+
+2019-12-18 Eric Botcazou <ebotcazou@adacore.com>
+
* einfo.ads (Handling of Type'Size Value): Add references to the
introduction of Object_Size in Ada 2020.
* sem_eval.adb (Subtypes_Statically_Match): Likewise.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 57d1631..871a309 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -3054,6 +3054,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
if (max_align < BIGGEST_ALIGNMENT)
TYPE_MAX_ALIGN (gnu_type) = max_align;
}
+
+ /* Similarly if an Object_Size clause has been specified. */
+ else if (Known_Esize (gnat_entity))
+ {
+ unsigned int max_size = UI_To_Int (Esize (gnat_entity));
+ unsigned int max_align = max_size & -max_size;
+ if (max_align < BIGGEST_ALIGNMENT)
+ TYPE_MAX_ALIGN (gnu_type) = max_align;
+ }
}
/* If we have a Parent_Subtype, make a field for the parent. If
@@ -4241,11 +4250,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
non-constant). */
if (!gnu_size && kind != E_String_Literal_Subtype)
{
- Uint gnat_size = Known_Esize (gnat_entity)
- ? Esize (gnat_entity) : RM_Size (gnat_entity);
- gnu_size
- = validate_size (gnat_size, gnu_type, gnat_entity, TYPE_DECL,
- false, Has_Size_Clause (gnat_entity), NULL, NULL);
+ if (Known_Esize (gnat_entity))
+ gnu_size
+ = validate_size (Esize (gnat_entity), gnu_type, gnat_entity,
+ VAR_DECL, false, false, NULL, NULL);
+ else
+ gnu_size
+ = validate_size (RM_Size (gnat_entity), gnu_type, gnat_entity,
+ TYPE_DECL, false, Has_Size_Clause (gnat_entity),
+ NULL, NULL);
}
/* If a size was specified, see if we can make a new type of that size
@@ -8872,6 +8885,8 @@ validate_size (Uint uint_size, tree gnu_type, Entity_Id gnat_object,
gnat_error_node = Last_Bit (Component_Clause (gnat_object));
else if (Present (Size_Clause (gnat_object)))
gnat_error_node = Expression (Size_Clause (gnat_object));
+ else if (Has_Object_Size_Clause (gnat_object))
+ gnat_error_node = Expression (Object_Size_Clause (gnat_object));
else
gnat_error_node = gnat_object;
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 4fc502b..ce2fe30 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -435,14 +435,6 @@ package body Layout is
end;
end if;
- -- If Esize is set, and RM_Size is not, RM_Size is copied from Esize.
- -- At least for now this seems reasonable, and is in any case needed
- -- for compatibility with old versions of gigi.
-
- if Known_Esize (E) and then Unknown_RM_Size (E) then
- Set_RM_Size (E, Esize (E));
- end if;
-
-- 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, except if a very large