diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-12-14 11:47:24 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-12-14 11:47:24 +0000 |
commit | 4d39941ea9e6fe059084be9f5dea7e29e055db91 (patch) | |
tree | cb51425855d3854723367fc3c5edb23fca63211e /gcc/ada/gcc-interface/decl.c | |
parent | 02aee327674dae6359d7b1e1a7434f039ba0c3d3 (diff) | |
download | gcc-4d39941ea9e6fe059084be9f5dea7e29e055db91.zip gcc-4d39941ea9e6fe059084be9f5dea7e29e055db91.tar.gz gcc-4d39941ea9e6fe059084be9f5dea7e29e055db91.tar.bz2 |
gigi.h (pad_type_has_rm_size): Declare.
* gcc-interface/gigi.h (pad_type_has_rm_size): Declare.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Do not build
a padding type for the alignment before validating the size.
Flip conditional construct and add a comment.
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Make sure to
apply the exception for padded objects to the type of the object.
* gcc-interface/utils.c (hash_pad_type): New static function.
(lookup_and_insert_pad_type): Rename into...
(canonicalize_pad_type): ...this. Call hash_pad_type, do only one
lookup with insertion and always return the canonical type.
(maybe_pad_type): Adjust to above changes. Set debug type later.
(pad_type_has_rm_size): New predicate.
(set_reverse_storage_order_on_pad_type): Adjust to above changes.
From-SVN: r255631
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index f626e61..f2da070 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -713,48 +713,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } /* If an alignment is specified, use it if valid. Note that exceptions - are objects but don't have an alignment. We must do this before we - validate the size, since the alignment can affect the size. */ - if (kind != E_Exception && Known_Alignment (gnat_entity)) - { - gcc_assert (Present (Alignment (gnat_entity))); - - align = validate_alignment (Alignment (gnat_entity), gnat_entity, - TYPE_ALIGN (gnu_type)); - - /* No point in changing the type if there is an address clause - as the final type of the object will be a reference type. */ - if (Present (Address_Clause (gnat_entity))) - align = 0; - else - { - tree orig_type = gnu_type; - - gnu_type - = maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity, - false, false, definition, true); - - /* If a padding record was made, declare it now since it will - never be declared otherwise. This is necessary to ensure - that its subtrees are properly marked. */ - if (gnu_type != orig_type && !DECL_P (TYPE_NAME (gnu_type))) - create_type_decl (TYPE_NAME (gnu_type), gnu_type, true, - debug_info_p, gnat_entity); - } - } - - /* If we are defining the object, see if it has a Size and validate it - if so. If we are not defining the object and a Size clause applies, - simply retrieve the value. We don't want to ignore the clause and - it is expected to have been validated already. Then get the new - type, if any. */ - if (definition) - gnu_size = validate_size (Esize (gnat_entity), gnu_type, - gnat_entity, VAR_DECL, false, - Has_Size_Clause (gnat_entity)); - else if (Has_Size_Clause (gnat_entity)) - gnu_size = UI_To_gnu (Esize (gnat_entity), bitsizetype); + are objects but don't have an alignment and there is also no point in + setting it for an address clause, since the final type of the object + will be a reference type. */ + if (Known_Alignment (gnat_entity) + && kind != E_Exception + && No (Address_Clause (gnat_entity))) + align = validate_alignment (Alignment (gnat_entity), gnat_entity, + TYPE_ALIGN (gnu_type)); + /* Likewise, if a size is specified, use it if valid. */ + if (Known_Esize (gnat_entity) && No (Address_Clause (gnat_entity))) + gnu_size + = validate_size (Esize (gnat_entity), gnu_type, gnat_entity, + VAR_DECL, false, Has_Size_Clause (gnat_entity)); if (gnu_size) { gnu_type @@ -4580,15 +4552,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_type = change_qualified_type (gnu_type, quals); } - if (!gnu_decl) - gnu_decl = create_type_decl (gnu_entity_name, gnu_type, - artificial_p, debug_info_p, - gnat_entity); - else + /* If we already made a decl, just set the type, otherwise create it. */ + if (gnu_decl) { TREE_TYPE (gnu_decl) = gnu_type; TYPE_STUB_DECL (gnu_type) = gnu_decl; } + else + gnu_decl = create_type_decl (gnu_entity_name, gnu_type, artificial_p, + debug_info_p, gnat_entity); } /* If we got a type that is not dummy, back-annotate the alignment of the |