diff options
author | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-05-08 17:18:20 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-05-08 17:25:12 +0200 |
commit | e34495985e49545c468e664ee10bd0e66c7395bf (patch) | |
tree | ee654f813c85e07812e4b4564d5078fef176cc32 /gcc/ada | |
parent | bb1ec4773a01e5bbb7cb6e2f53ea338a74a6797f (diff) | |
download | gcc-e34495985e49545c468e664ee10bd0e66c7395bf.zip gcc-e34495985e49545c468e664ee10bd0e66c7395bf.tar.gz gcc-e34495985e49545c468e664ee10bd0e66c7395bf.tar.bz2 |
Fix uniqueness of address for aliased objects
Two aliased objects must have distinct addresses, even if they have
size zero, so we make sure to allocate at least one byte for them.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Force at
least the unit size for an aliased object of a constrained nominal
subtype whose size is variable.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 15 |
2 files changed, 18 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9644e01..35d1114 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 2020-05-08 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Force at + least the unit size for an aliased object of a constrained nominal + subtype whose size is variable. + +2020-05-08 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Deal with artificial maximally-sized types designed by access types. * gcc-interface/utils.c (packable_type_hash): New structure. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index a4053ee..9c1acd9 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -969,10 +969,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) align = MINIMUM_ATOMIC_ALIGNMENT; #endif - /* Make a new type with the desired size and alignment, if needed. - But do not take into account alignment promotions to compute the - size of the object. */ + /* Do not take into account aliased adjustments or alignment promotions + to compute the size of the object. */ tree gnu_object_size = gnu_size ? gnu_size : TYPE_SIZE (gnu_type); + + /* If the object is aliased, of a constrained nominal subtype and its + size might be zero at run time, we force at least the unit size. */ + if (Is_Aliased (gnat_entity) + && !Is_Constr_Subt_For_UN_Aliased (gnat_type) + && Is_Array_Type (Underlying_Type (gnat_type)) + && !TREE_CONSTANT (gnu_object_size)) + gnu_size = size_binop (MAX_EXPR, gnu_object_size, bitsize_unit_node); + + /* Make a new type with the desired size and alignment, if needed. */ if (gnu_size || align > 0) { tree orig_type = gnu_type; |